|
001 packagepackage is used to name the directory or folder a class is in Min_Kim;
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 * All about my game.
009 * @authorthis is the Javadoc tag for documenting who created the source code My Name Here
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 InterArt 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 /** declaring image sprite*/
014 privateprivate is used to restrict access to the current class only ImageSprite face;
015 /** declaring spinner*/
016 privateprivate is used to restrict access to the current class only Spinner spinner1, spinner2;
017 /**ovalSprite making circles and ovals*/
018 privateprivate is used to restrict access to the current class only OvalSprite eye1, eye2, eye3, eye4, mouth1, mouth2, ball;
019 /**string*/
020 privateprivate is used to restrict access to the current class only StringSprite title, name;
021 /**rectangle*/
022 privateprivate is used to restrict access to the current class only RectangleSprite rec1, rec2, rec3;
023 /**outline which change sprite to an outline*/
024 privateprivate is used to restrict access to the current class only OutlineSprite boundary5;
025 /**projectile bounce*/
026 privateprivate is used to restrict access to the current class only ProjectileTransformer projectile;
027 /**clickcount stating its an integer and starts out with 0*/
028 privateprivate is used to restrict access to the current class only intint is the type for whole numbers and it is short for integer clickcount;
029 /**sound1*/
030 privateprivate is used to restrict access to the current class only Sound sound1=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor Sound("Mouse-doubleclick-01.wav");
031 /**sound2*/
032 privateprivate is used to restrict access to the current class only Sound sound2=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor Sound("Hit-02.wav");
033 /**sets up the game*/
034 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value setup()
035 {open braces start code blocks and must be matched with a close brace
036 face();
037 eye1();
038 eye2();
039 eye3();
040 eye4();
041 rectangle();
042 rectangleSecond();
043 help();
044 boundary();
045 nameArt();
046 makeBall();
047 makeMouth();
048 moveRight();
049 moveLeft();
050
051 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);
052 ball.setTracker(projectile);
053 }close braces end code blocks and must match an earlier open brace
054 /**makes the help text when you click on the help button*/
055 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value help()
056 {open braces start code blocks and must be matched with a close brace
057 String helpText=this assignment operator makes the left side equal to the right side
058 "Hello Welcome to Wackyface Interaction Art<br>"+adds two numbers together or concatenates Strings together
059 "press z to make the right eye ball move to the right<br>"+adds two numbers together or concatenates Strings together
060 "click on the right right eye ball,<br>"+adds two numbers together or concatenates Strings together
061 "and wait till it changes color<br> "+adds two numbers together or concatenates Strings together
062 "click x to make clicking sound work and c to make hit sound work";
063 setHelpText(helpText);
064 }close braces end code blocks and must match an earlier open brace
065 /**making boundary outside the face*/
066 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value boundary()
067 {open braces start code blocks and must be matched with a close brace
068 rec1=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor RectangleSprite(2,2);
069 boundary5=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor OutlineSprite(rec1);
070 boundary5.setScale(1.0);
071 boundary5.setColor(Palette.getColor("Black"));
072 boundary5.setLineThickness(0.0001);
073 boundary5.setLocation(0.5, 0.5);
074 addSprite(boundary5);
075 }close braces end code blocks and must match an earlier open brace
076 /**making a yellow ball*/
077 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value makeBall()
078 {open braces start code blocks and must be matched with a close brace
079 ball=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor OvalSprite(1,1);
080 ball.setScale(0.01);
081 ball.setLocation(0.5, 0.5);
082 ball.setColor(Palette.getColor("yellow"));
083 addSprite(ball);
084 }close braces end code blocks and must match an earlier open brace
085 /** making a rectangle and adding a spinner*/
086 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value rectangle()
087 {open braces start code blocks and must be matched with a close brace
088 rec2=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor RectangleSprite(1,1);
089 rec2.setScale(0.1);
090 rec2.setLocation(0.2, 0.5);
091 rec2.setColor(Palette.getColor("red"));
092 addSprite(rec2);
093
094 Spinner spinner;
095 spinner=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor Spinner(0);
096 spinner.setRotationDegrees(65);
097 rec2.addTransformer(spinner);
098 }close braces end code blocks and must match an earlier open brace
099 /** making a rectangle and adding a spinner*/
100 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value rectangleSecond()
101 {open braces start code blocks and must be matched with a close brace
102 rec3=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor RectangleSprite(1,1);
103 rec3.setScale(0.1);
104 rec3.setLocation(0.7, 0.5);
105 rec3.setColor(Palette.getColor("red"));
106 addSprite(rec3);
107
108 Spinner spinner2;
109 spinner2=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor Spinner(0);
110 spinner2.setRotationDegrees(65);
111 rec3.addTransformer(spinner2);
112 }close braces end code blocks and must match an earlier open brace
113 /**making image in the background*/
114 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value face()
115 {open braces start code blocks and must be matched with a close brace
116 face=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor ImageSprite("Face.JPG");
117 face.setLocation(0.5, 0.5);
118 addSprite(face);
119 }close braces end code blocks and must match an earlier open brace
120 /**add a Text In the background the name of the title
121 and the name of the author*/
122 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value nameArt()
123 {open braces start code blocks and must be matched with a close brace
124 title=this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor StringSprite("The Wacky Face");
125 title.setScale(0.3);
126 title.setLocation(0.5, 0.05);
127 title.setColor(Palette.getColor("White"));
128 canvas.addSprite(title);
129
130 name=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor StringSprite("Min Kim");
131 name.setScale(0.2);
132 name.setLocation(0.5, 0.95);
133 name.setColor(Palette.getColor("White"));
134 canvas.addSprite(name);
135 }close braces end code blocks and must match an earlier open brace
136 /**making an eye outline with hollow*/
137 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value eye1()
138 {open braces start code blocks and must be matched with a close brace
139 eye1=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor OvalSprite (2, 1);
140 OutlineSprite outline1=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor OutlineSprite(eye1);
141 outline1.setSize(.3);
142 outline1.setLineThickness(0.2);
143 outline1.setLocation(.2, .3);
144 canvas.addSprite(outline1);
145 }close braces end code blocks and must match an earlier open brace
146 /**making an second eye on the right side*/
147 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value eye2()
148 {open braces start code blocks and must be matched with a close brace
149 eye2=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor OvalSprite(2, 1);
150 OutlineSprite outline2=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor OutlineSprite(eye2);
151 outline2.setSize(.3);
152 outline2.setLineThickness(0.2);
153 outline2.setLocation(.7, .3);
154 canvas.addSprite(outline2);
155 }close braces end code blocks and must match an earlier open brace
156 /**make eye ball inside the eye*/
157 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value eye3()
158 {open braces start code blocks and must be matched with a close brace
159 eye3=this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor OvalSprite(1,1);
160 eye3.setSize(.05);
161 eye3.setLocation(.2,.3);
162 canvas.addSprite(eye3);
163 }close braces end code blocks and must match an earlier open brace
164 /**makes the left eye left movement*/
165 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value moveLeft()
166 {open braces start code blocks and must be matched with a close brace
167 OutlineTransformer left;
168 left=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor OutlineTransformer(0.25,
169 0.2, 0.3,
170 0.1, 0.3,
171 0.2, 0.3);
172 left.setLooping(falsefalse is a value for the boolean type and means not true);
173
174 eye3.addTransformer(left);
175 eye3.setLocation(left.getCurrentPoint());
176 addSprite(eye3);
177 }close braces end code blocks and must match an earlier open brace
178 /**makes the right eye ball*/
179 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value eye4()
180 {open braces start code blocks and must be matched with a close brace
181 eye4=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor OvalSprite(1,1);
182 eye4.setSize(.05);
183 eye4.setLocation(.7, .3);
184 canvas.addSprite(eye4);
185 }close braces end code blocks and must match an earlier open brace
186 /**makes the right eye ball move right in the beginning*/
187 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value moveRight()
188 {open braces start code blocks and must be matched with a close brace
189 OutlineTransformer right;
190 right=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor OutlineTransformer(0.25,
191 0.7, 0.3,
192 0.8, 0.3,
193 0.7, 0.3);
194 right.setLooping(falsefalse is a value for the boolean type and means not true);
195
196 eye4.addTransformer(right);
197 eye4.setLocation(right.getCurrentPoint());
198 addSprite(eye4);
199 }close braces end code blocks and must match an earlier open brace
200 /**makes the outline of oval that looks like a mouth one small and one big
201 also used a blinker*/
202 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value makeMouth()
203 {open braces start code blocks and must be matched with a close brace
204 mouth1=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor OvalSprite(2, 1);
205 mouth1.setScale(0.4);
206 mouth1.setLocation(0.5, 0.7);
207 mouth1.setColor(Palette.getColor("red"));
208 canvas.addSprite(mouth1);
209
210 mouth2=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor OvalSprite(2, 1);
211 mouth2.setScale(0.2);
212 mouth2.setLocation(0.5, 0.7);
213 mouth2.setColor(Palette.getColor("red"));
214 canvas.addSprite(mouth2);
215
216 schedule(newnew is used to create objects by calling the constructor Blinker(), .5);
217 }close braces end code blocks and must match an earlier open brace
218
219 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
220 {open braces start code blocks and must be matched with a close brace
221 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value act()
222 {open braces start code blocks and must be matched with a close brace
223 booleanboolean is a type that is either true or false vis=this assignment operator makes the left side equal to the right sidemouth1.isVisible();
224 mouth1.setVisible(!this is the not operator, which changes true to false and false to truevis);
225 schedule(thisthis means the current object (the implicit parameter), .5);
226 }close braces end code blocks and must match an earlier open brace
227 }close braces end code blocks and must match an earlier open brace
228 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
229 {open braces start code blocks and must be matched with a close brace
230 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value act()
231 {open braces start code blocks and must be matched with a close brace
232 eye4.setColor(getColor("white"));
233 }close braces end code blocks and must match an earlier open brace
234 }close braces end code blocks and must match an earlier open brace
235 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value handleCollisions()
236 {open braces start code blocks and must be matched with a close brace
237 ball.bounceOffOf(boundary5);
238 ball.bounceOffOf(eye1);
239 ball.bounceOffOf(eye2);
240 ball.bounceOffOf(mouth1);
241 ball.bounceOffOf(mouth2);
242 }close braces end code blocks and must match an earlier open brace
243 /**handle input and game events*/
244 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value advance()
245 {open braces start code blocks and must be matched with a close brace
246 handleCollisions();
247 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 'z')
248 {open braces start code blocks and must be matched with a close brace
249 moveRight();
250 }close braces end code blocks and must match an earlier open brace
251 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 'a')
252 {open braces start code blocks and must be matched with a close brace
253 moveLeft();
254 }close braces end code blocks and must match an earlier open brace
255 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 'x')
256 {open braces start code blocks and must be matched with a close brace
257 playSoundImmediately();
258 sound1.setVolume(.8);
259 sound1.loop();
260 }close braces end code blocks and must match an earlier open brace
261 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')
262 {open braces start code blocks and must be matched with a close brace
263 playSoundImmediately();
264 sound2.setVolume(.2);
265 sound2.loop();
266 }close braces end code blocks and must match an earlier open brace
267 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)
268 {open braces start code blocks and must be matched with a close brace
269 schedule(newnew is used to create objects by calling the constructor DelayedResponse(), 1.5);
270 }close braces end code blocks and must match an earlier open brace
271 }close braces end code blocks and must match an earlier open brace
272 }close braces end code blocks and must match an earlier open brace
|