|
001 packagepackage is used to name the directory or folder a class is in Drew_Schwarz;
002
003 importimport means to make the classes and/or packages available in this program fang.*;
004 importimport means to make the classes and/or packages available in this program java.awt.*;
005 importimport means to make the classes and/or packages available in this program java.awt.geom.*;
006
007 /**
008 * Creates a game that uses interactive art.
009 * @authorthis is the Javadoc tag for documenting who created the source code Drew Schwarz
010 */
011 publicpublic is used to indicate unrestricted access (any other class can have access) classclass is a group of fields and methods used for making objects Assignment6 extendsextends means to customize or extend the functionality of a class Game
012 {open braces start code blocks and must be matched with a close brace
013 privateprivate is used to restrict access to the current class only Sound sound=this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor Sound("DingLower.wav");
014 privateprivate is used to restrict access to the current class only Sound dohs=this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor Sound("32dohs.wav");
015 privateprivate is used to restrict access to the current class only ImageSprite nose;
016 privateprivate is used to restrict access to the current class only ImageSprite eyeone;
017 privateprivate is used to restrict access to the current class only ImageSprite eyetwo;
018 privateprivate is used to restrict access to the current class only ImageSprite mouth;
019 privateprivate is used to restrict access to the current class only OvalSprite spin;
020 privateprivate is used to restrict access to the current class only OvalSprite bounce;
021 privateprivate is used to restrict access to the current class only OutlineSprite boundarytwo;
022 privateprivate is used to restrict access to the current class only ProjectileTransformer projectile;
023 privateprivate is used to restrict access to the current class only intint is the type for whole numbers and it is short for integer circles =this assignment operator makes the left side equal to the right side 15, i=this assignment operator makes the left side equal to the right side2;
024 privateprivate is used to restrict access to the current class only doubledouble is the type for numbers that can contain decimal fractions area =this assignment operator makes the left side equal to the right side 360.0/circles;
025 StringSprite titalspin =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor StringSprite("Spining Room by Drew Schwarz");
026 StringSprite titalcrazy =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor StringSprite("Crazy Face by Drew Schwarz");
027 StringSprite title =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor StringSprite("Assignment 6 The art program.To get more info use the help button.");
028
029
030 /**sets up the help screen of the game as well as the best part of the game*/
031 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value setup()
032 {open braces start code blocks and must be matched with a close brace
033 removeAllSprites();
034 String helpText=this assignment operator makes the left side equal to the right side
035 "Hello this page helps you to learn<br>"+adds two numbers together or concatenates Strings together
036 "how to run this application<br>"+adds two numbers together or concatenates Strings together
037 "First you can press R, C, or O to swich between the Spining Room (R) the Craze Face(C) or the title page(O).<br>"+adds two numbers together or concatenates Strings together
038 "While in the Spining Room hold down the M key and click in the game area to set the spining shape.<br>"+adds two numbers together or concatenates Strings together
039 "While on the Craze Face click the eyeballs or nose to change thier collor.";
040 setHelpText(helpText);
041 title.setLocation(.5,.3);
042 title.setSize(.9);
043 addSprite(title);
044 bounce();
045
046 }close braces end code blocks and must match an earlier open brace
047
048 /**Adds the ding soud to the program*/
049 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value sound()
050 {open braces start code blocks and must be matched with a close brace
051 sound.play(0.1);
052 }close braces end code blocks and must match an earlier open brace
053
054 /**Adds the Dohs sound to the program*/
055 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value dohs()
056 {open braces start code blocks and must be matched with a close brace
057 dohs.play (0.9);
058 }close braces end code blocks and must match an earlier open brace
059
060 /** Creates a spining room application where the User determans the placment of further sprites */
061 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value spiningroom()
062 {open braces start code blocks and must be matched with a close brace
063 forfor is a looping structure for repeatedly executing a block of code (intint is the type for whole numbers and it is short for integer i=this assignment operator makes the left side equal to the right side2; i <=this evaluates to true if the left side is not more than the right side circles; i++this is the increment operator, which increases the variable by 1)
064 {open braces start code blocks and must be matched with a close brace
065 spin=this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor OvalSprite(.5,1);
066 spin.setLocation(.5,.5);
067 spin.setSize(1.0-(1.0*(i-1)/circles));
068 spin.rotateDegrees(circles +adds two numbers together or concatenates Strings together (i-1)*area);
069 ifif executes the next statement only if the condition in parenthesis evaluates to true (i%this divides the left side by the right side and evaluates to the remainder2==this is the comparison operator which evaluates to true if both sides are the same0)
070 spin.setColor(Palette.getColor("Yellow"));
071 elseelse is what happens when the if condition is false
072 spin.setColor(Palette.getColor("Red"));
073 addSprite(spin);
074
075 Spinner spinner;
076 spinner=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor Spinner(0);
077 spinner.setRotationDegrees(45);
078
079 spin.addTransformer(spinner);
080 }close braces end code blocks and must match an earlier open brace
081 }close braces end code blocks and must match an earlier open brace
082
083 classclass is a group of fields and methods used for making objects DelayedResponse extendsextends means to customize or extend the functionality of a class TimedAction
084 {open braces start code blocks and must be matched with a close brace
085 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value act()
086 {open braces start code blocks and must be matched with a close brace
087 forfor is a looping structure for repeatedly executing a block of code (intint is the type for whole numbers and it is short for integer i=this assignment operator makes the left side equal to the right side2; i <=this evaluates to true if the left side is not more than the right side circles; i++this is the increment operator, which increases the variable by 1)
088 {open braces start code blocks and must be matched with a close brace
089 spin.setSize(1.0-(1.0*(i-1)/circles));
090 spin.rotateDegrees(circles +adds two numbers together or concatenates Strings together (i-1)*area);
091 ifif executes the next statement only if the condition in parenthesis evaluates to true (i%this divides the left side by the right side and evaluates to the remainder2==this is the comparison operator which evaluates to true if both sides are the same0)
092 spin.setColor(Palette.getColor("White"));
093 elseelse is what happens when the if condition is false
094 spin.setColor(Palette.getColor("Black"));
095 addSprite(spin);
096
097 Spinner spinner;
098 spinner=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor Spinner(0);
099 spinner.setRotationDegrees(45);
100
101 spin.addTransformer(spinner);
102 }close braces end code blocks and must match an earlier open brace
103 }close braces end code blocks and must match an earlier open brace
104 }close braces end code blocks and must match an earlier open brace
105
106
107 /** Makes more sprites in the game when you click the mouse*/
108 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value makeMore()
109 {open braces start code blocks and must be matched with a close brace
110 forfor is a looping structure for repeatedly executing a block of code (intint is the type for whole numbers and it is short for integer i=this assignment operator makes the left side equal to the right side2; i <=this evaluates to true if the left side is not more than the right side circles; i++this is the increment operator, which increases the variable by 1)
111 {open braces start code blocks and must be matched with a close brace
112 spin=this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor OvalSprite(.5,1);
113 spin.setLocation(getMouse2D());
114 spin.setSize(1.0-(1.0*(i-1)/circles));
115 spin.rotateDegrees(circles +adds two numbers together or concatenates Strings together (i-1)*area);
116 ifif executes the next statement only if the condition in parenthesis evaluates to true (i%this divides the left side by the right side and evaluates to the remainder2==this is the comparison operator which evaluates to true if both sides are the same0)
117 spin.setColor(Palette.getColor("Yellow"));
118 elseelse is what happens when the if condition is false
119 spin.setColor(Palette.getColor("Red"));
120 addSprite(spin);
121
122 Spinner spinner;
123 spinner=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor Spinner(0);
124 spinner.setRotationDegrees(45);
125
126 spin.addTransformer(spinner);
127
128 schedule(newnew is used to create objects by calling the constructor DelayedResponse(),.5);
129 }close braces end code blocks and must match an earlier open brace
130 }close braces end code blocks and must match an earlier open brace
131
132 /**adds the crazyface application to the game*/
133 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value crazyface()
134 {open braces start code blocks and must be matched with a close brace
135 mouth();
136 eyes();
137 nose();
138 }close braces end code blocks and must match an earlier open brace
139
140 /**creates a mouth image under the nose*/
141 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value mouth()
142 {open braces start code blocks and must be matched with a close brace
143 mouth=this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor ImageSprite("Mouth.gif");
144 mouth.setLocation(.5, .9);
145 mouth.setSize(.4);
146 addSprite(mouth);
147 }close braces end code blocks and must match an earlier open brace
148
149 /** creates a set of eye immages under in the craze face application*/
150 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value eyes()
151 {open braces start code blocks and must be matched with a close brace
152 eyeone=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor ImageSprite("Eyeone.gif");
153 eyeone.setLocation(.2, .3);
154 eyeone.setSize(.4);
155 addSprite(eyeone);
156
157 eyetwo=this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor ImageSprite("Eyetwo.jpg");
158 eyetwo.setLocation(.8, .3);
159 eyetwo.setSize(.5);
160 addSprite(eyetwo);
161
162 schedule(newnew is used to create objects by calling the constructor Blinker(), 1);
163 }close braces end code blocks and must match an earlier open brace
164
165 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value nose()
166 {open braces start code blocks and must be matched with a close brace
167 nose=this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor ImageSprite("nose.gif");
168 nose.setLocation(.5,.6);
169 nose.setSize(.3);
170 addSprite(nose);
171 }close braces end code blocks and must match an earlier open brace
172
173 /** creates a bounsing ball in the opening application*/
174 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value bounce()
175 {open braces start code blocks and must be matched with a close brace
176 boundarytwo=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor OutlineSprite(newnew is used to create objects by calling the constructor PolygonSprite(5));
177 boundarytwo.setSize(0.5);
178 boundarytwo.setLineThickness(0.2);
179 boundarytwo.setLocation(0.5, 0.8);
180 addSprite(boundarytwo);
181
182 bounce=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor OvalSprite(0.1, 0.1);
183 bounce.setLocation(0.5, 0.8);
184 addSprite(bounce);
185
186 projectile=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor ProjectileTransformer(0.1, 0.25);
187 bounce.setTracker(projectile);
188 }close braces end code blocks and must match an earlier open brace
189
190 /** can handale the collisions of the eyetwo sprite
191 *when placed alown in the advaced method
192 */
193 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value handleCollisions()
194 {open braces start code blocks and must be matched with a close brace
195 ifif executes the next statement only if the condition in parenthesis evaluates to true(bounce.intersects(boundarytwo))
196 {open braces start code blocks and must be matched with a close brace
197 Vector2D vector=this assignment operator makes the left side equal to the right sideprojectile.getVector2D();
198 vector.turnDegrees(90);
199 projectile.setVector2D(vector);
200 }close braces end code blocks and must match an earlier open brace
201 }close braces end code blocks and must match an earlier open brace
202
203 classclass is a group of fields and methods used for making objects Blinker extendsextends means to customize or extend the functionality of a class TimedAction
204 {open braces start code blocks and must be matched with a close brace
205 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value act()
206 {open braces start code blocks and must be matched with a close brace
207 booleanboolean is a type that is either true or false vis=this assignment operator makes the left side equal to the right sideeyeone.isVisible();
208 eyeone.setVisible(!this is the not operator, which changes true to false and false to truevis);
209 schedule(thisthis means the current object (the implicit parameter), 1);
210 }close braces end code blocks and must match an earlier open brace
211 }close braces end code blocks and must match an earlier open brace
212
213
214 /**handle input and game events*/
215 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value advance()
216 {open braces start code blocks and must be matched with a close brace
217 handleCollisions();
218
219 ifif executes the next statement only if the condition in parenthesis evaluates to true(getKeyPressed()==this is the comparison operator which evaluates to true if both sides are the same'r')
220 {open braces start code blocks and must be matched with a close brace
221 removeAllSprites();
222 spiningroom();
223 sound();
224 titalspin.setLocation(.5, .9);
225 titalspin.setSize(.5);
226 addSprite(titalspin);
227 }close braces end code blocks and must match an earlier open brace
228 ifif executes the next statement only if the condition in parenthesis evaluates to true (getKeyPressed()==this is the comparison operator which evaluates to true if both sides are the same'c')
229 {open braces start code blocks and must be matched with a close brace
230 removeAllSprites();
231 crazyface();
232 titalcrazy.setLocation(.5, .1);
233 titalcrazy.setSize(.5);
234 addSprite(titalcrazy);
235 dohs();
236 }close braces end code blocks and must match an earlier open brace
237
238 ifif executes the next statement only if the condition in parenthesis evaluates to true (getKeyPressed()==this is the comparison operator which evaluates to true if both sides are the same'o')
239 {open braces start code blocks and must be matched with a close brace
240 setup();
241 }close braces end code blocks and must match an earlier open brace
242
243 ifif executes the next statement only if the condition in parenthesis evaluates to true (getKeyPressed()==this is the comparison operator which evaluates to true if both sides are the same'm')
244 {open braces start code blocks and must be matched with a close brace
245 ifif executes the next statement only if the condition in parenthesis evaluates to true (getClick2D()!=this is the not equals operator which evaluates to true if both sides are differentnullnull is the value used to refer to a non-existant object)
246 makeMore();
247 }close braces end code blocks and must match an earlier open brace
248 }close braces end code blocks and must match an earlier open brace
249 }close braces end code blocks and must match an earlier open brace
|