|
001 packagepackage is used to name the directory or folder a class is in alyday;
002
003 importimport means to make the classes and/or packages available in this program wiki.Wiki;
004 importimport means to make the classes and/or packages available in this program fang.*;
005 importimport means to make the classes and/or packages available in this program java.awt.*;
006 importimport means to make the classes and/or packages available in this program java.awt.geom.*;
007 importimport means to make the classes and/or packages available in this program java.util.*;
008
009 /**
010 * All about my game here.
011 * @authorthis is the Javadoc tag for documenting who created the source code Alyday
012 */
013 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 fightK extendsextends means to customize or extend the functionality of a class GameLoop
014 {open braces start code blocks and must be matched with a close brace
015 /**These set up the ImageSprites*/
016 privateprivate is used to restrict access to the current class only ImageSprite kid;
017 privateprivate is used to restrict access to the current class only ImageSprite kaufman;
018 privateprivate is used to restrict access to the current class only ImageSprite background;
019 privateprivate is used to restrict access to the current class only ImageSprite diploma;
020 /**These set up the StringSprites*/
021 privateprivate is used to restrict access to the current class only StringSprite win;
022 privateprivate is used to restrict access to the current class only StringSprite lose;
023 privateprivate is used to restrict access to the current class only StringSprite gpa;
024 privateprivate is used to restrict access to the current class only StringSprite life;
025 /**These set up the ints that will be used in adjusting gpa and life*/
026 privateprivate is used to restrict access to the current class only intint is the type for whole numbers and it is short for integer updateGPA;
027 privateprivate is used to restrict access to the current class only intint is the type for whole numbers and it is short for integer lives;
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 /**These set up the Strings of apples and Fs*/
030 privateprivate is used to restrict access to the current class only ImageSprite[brackets are typically used to declare, initialize and index (indicate which element of) arrays]brackets are typically used to declare, initialize and index (indicate which element of) arrays toss;
031 privateprivate is used to restrict access to the current class only StringSprite[brackets are typically used to declare, initialize and index (indicate which element of) arrays]brackets are typically used to declare, initialize and index (indicate which element of) arrays fail;
032 /**These set up the tracker*/
033 privateprivate is used to restrict access to the current class only ProjectileTracker tracker;
034
035 /**sets up the game by making the sprites and adding them, as well as setting up the initial values of gpa and life*/
036 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value startGame()
037 {open braces start code blocks and must be matched with a close brace
038 updateGPA=this assignment operator makes the left side equal to the right side0;
039 lives=this assignment operator makes the left side equal to the right side3;
040 makeSprites();
041 addSprites();
042 clickCount=this assignment operator makes the left side equal to the right side0;
043 }close braces end code blocks and must match an earlier open brace
044
045 /**makes the sprites*/
046 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value makeSprites()
047 {open braces start code blocks and must be matched with a close brace
048 /**thisthis means the current object (the implicit parameter) sets the scale, location, and image forfor is a looping structure for repeatedly executing a block of code the ImageSprite background*/
049 background=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor ImageSprite("Ggc.jpg");
050 background.setScale(2.0);
051 background.setLocation(0.5, 0.5);
052
053 /**thisthis means the current object (the implicit parameter) sets the scale, location, and image forfor is a looping structure for repeatedly executing a block of code the ImageSprite kid, using the people method*/
054 kid=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor ImageSprite("Student.jpg");
055 people(kid, 0.12, 0.5);
056
057 /**thisthis means the current object (the implicit parameter) sets the scale, location, and image forfor is a looping structure for repeatedly executing a block of code the ImageSprite kaufman, using the people method*/
058 kaufman=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor ImageSprite ("Kaufman.jpg");
059 people(kaufman, 0.87, 0.5);
060
061 /**thisthis means the current object (the implicit parameter) sets the scale, location, and image forfor is a looping structure for repeatedly executing a block of code the ImageSprite[brackets are typically used to declare, initialize and index (indicate which element of) arrays]brackets are typically used to declare, initialize and index (indicate which element of) arrays toss, using the throwing method*/
062 toss=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor ImageSprite[brackets are typically used to declare, initialize and index (indicate which element of) arrays5]brackets are typically used to declare, initialize and index (indicate which element of) arrays;
063 throwing(toss, "Apple.gif");
064
065 /**thisthis means the current object (the implicit parameter) sets the scale, location, and image forfor is a looping structure for repeatedly executing a block of code the StringSprite[brackets are typically used to declare, initialize and index (indicate which element of) arrays]brackets are typically used to declare, initialize and index (indicate which element of) arrays fail, using the throwing method*/
066 fail=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor StringSprite[brackets are typically used to declare, initialize and index (indicate which element of) arrays5]brackets are typically used to declare, initialize and index (indicate which element of) arrays;
067 throwing1(fail, "F");
068
069 /**thisthis means the current object (the implicit parameter) sets the scale, location, and image forfor is a looping structure for repeatedly executing a block of code the StringSprite gpa, using the display method*/
070 gpa=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor StringSprite("Current GPA:"+adds two numbers together or concatenates Strings togetherupdateGPA);
071 display(gpa, 0.15);
072
073 /**thisthis means the current object (the implicit parameter) sets the scale, location, and image forfor is a looping structure for repeatedly executing a block of code the StringSprite life, using the display method*/
074 life=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor StringSprite("Lives:"+adds two numbers together or concatenates Strings togetherlives+adds two numbers together or concatenates Strings together"");
075 display(life, 0.08);
076
077 /**thisthis means the current object (the implicit parameter) sets the scale, location, font, color and image forfor is a looping structure for repeatedly executing a block of code the StringSprite lose, using the end method*/
078 lose=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor StringSprite("YOU LOSE!");
079 lose.setColor(Color.RED);
080 end(lose, "Chiller");
081
082 /**thisthis means the current object (the implicit parameter) sets the scale, location, font, color and image forfor is a looping structure for repeatedly executing a block of code the StringSprite win, using the end method*/
083 win=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor StringSprite("Congratulations! You can graduate!");
084 win.setColor(Color.WHITE);
085 end(win, "Bauhaus 93");
086
087 /**thisthis means the current object (the implicit parameter) sets the scale, location, and image forfor is a looping structure for repeatedly executing a block of code the ImageSprite diploma, using the people method*/
088 diploma=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor ImageSprite("Diploma.gif");
089 people(diploma, 0.5, 0.3);
090
091 /** thisthis means the current object (the implicit parameter) calls on the method makeTracker, to make the tracker forfor is a looping structure for repeatedly executing a block of code the game*/
092 makeTracker();
093 }close braces end code blocks and must match an earlier open brace
094 /**This provides the information to make the tracker that moves the kaufman sprite*/
095 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value makeTracker()
096 {open braces start code blocks and must be matched with a close brace
097 tracker=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor ProjectileTracker(0.0, random.nextDouble());
098 tracker.setAngularVelocity(0);
099 kaufman.setTracker(tracker);
100 }close braces end code blocks and must match an earlier open brace
101 /**This sets up the method, that when I call on it, it will update lives*/
102 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value refreshLives()
103 {open braces start code blocks and must be matched with a close brace
104 life.setText("Lives: "+adds two numbers together or concatenates Strings togetherlives);
105 }close braces end code blocks and must match an earlier open brace
106 /**This sets up the method, that when I call on it, it will update updateGPA*/
107 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value refreshUpdateGPA()
108 {open braces start code blocks and must be matched with a close brace
109 gpa.setText("Current GPA: "+adds two numbers together or concatenates Strings togetherupdateGPA);
110 }close braces end code blocks and must match an earlier open brace
111 /**adds the sprites to the screen*/
112 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value addSprites()
113 {open braces start code blocks and must be matched with a close brace
114 canvas.addSprite(background);
115 canvas.addSprite(kid);
116 canvas.addSprite(kaufman);
117 canvas.addSprite(toss);
118 canvas.addSprite(fail);
119 canvas.addSprite(life);
120 canvas.addSprite(gpa);
121 }close braces end code blocks and must match an earlier open brace
122 /**This sets the lives and gpa StringSprites*/
123 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value display(StringSprite word, doubledouble is the type for numbers that can contain decimal fractions b)
124 {open braces start code blocks and must be matched with a close brace
125 word.setScale(0.35);
126 word.setLocation(0.2,b);
127 word.setFontFamilyName("Bauhaus 93");
128 word.setColor(Color.GREEN);
129 }close braces end code blocks and must match an earlier open brace
130 /**This sets the win and lose StringSprites*/
131 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value end(StringSprite word, String font)
132 {open braces start code blocks and must be matched with a close brace
133 word.setScale(0.75);
134 word.setLocation(0.5, 0.5);
135 word.setFontFamilyName(font);
136 }close braces end code blocks and must match an earlier open brace
137 /**This sets all that ImageSprites that use the method people*/
138 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value people(ImageSprite pic, doubledouble is the type for numbers that can contain decimal fractions a, doubledouble is the type for numbers that can contain decimal fractions b)
139 {open braces start code blocks and must be matched with a close brace
140 pic.setScale(0.25);
141 pic.setLocation(a, b);
142 }close braces end code blocks and must match an earlier open brace
143 /**This sets up the array forfor is a looping structure for repeatedly executing a block of code toss*/
144 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value throwing(ImageSprite[brackets are typically used to declare, initialize and index (indicate which element of) arrays]brackets are typically used to declare, initialize and index (indicate which element of) arrays thrown, String name)
145 {open braces start code blocks and must be matched with a close brace
146 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 k=this assignment operator makes the left side equal to the right side0; k<thrown.length; k++this is the increment operator, which increases the variable by 1)
147 {open braces start code blocks and must be matched with a close brace
148 thrown[brackets are typically used to declare, initialize and index (indicate which element of) arraysk]brackets are typically used to declare, initialize and index (indicate which element of) arrays=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor ImageSprite(name);
149 thrown[brackets are typically used to declare, initialize and index (indicate which element of) arraysk]brackets are typically used to declare, initialize and index (indicate which element of) arrays.setScale(0.1);
150 thrown[brackets are typically used to declare, initialize and index (indicate which element of) arraysk]brackets are typically used to declare, initialize and index (indicate which element of) arrays.setVisible(falsefalse is a value for the boolean type and means not true);
151 thrown[brackets are typically used to declare, initialize and index (indicate which element of) arraysk]brackets are typically used to declare, initialize and index (indicate which element of) arrays.setColor(Color.RED);
152 }close braces end code blocks and must match an earlier open brace
153 }close braces end code blocks and must match an earlier open brace
154 /**This sets up the array forfor is a looping structure for repeatedly executing a block of code fail*/
155 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value throwing1(StringSprite[brackets are typically used to declare, initialize and index (indicate which element of) arrays]brackets are typically used to declare, initialize and index (indicate which element of) arrays thrown, String name)
156 {open braces start code blocks and must be matched with a close brace
157 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 k=this assignment operator makes the left side equal to the right side0; k<thrown.length; k++this is the increment operator, which increases the variable by 1)
158 {open braces start code blocks and must be matched with a close brace
159 thrown[brackets are typically used to declare, initialize and index (indicate which element of) arraysk]brackets are typically used to declare, initialize and index (indicate which element of) arrays=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor StringSprite(name);
160 thrown[brackets are typically used to declare, initialize and index (indicate which element of) arraysk]brackets are typically used to declare, initialize and index (indicate which element of) arrays.setScale(0.1);
161 thrown[brackets are typically used to declare, initialize and index (indicate which element of) arraysk]brackets are typically used to declare, initialize and index (indicate which element of) arrays.setVisible(falsefalse is a value for the boolean type and means not true);
162 thrown[brackets are typically used to declare, initialize and index (indicate which element of) arraysk]brackets are typically used to declare, initialize and index (indicate which element of) arrays.setColor(Color.RED);
163 }close braces end code blocks and must match an earlier open brace
164 }close braces end code blocks and must match an earlier open brace
165 /**This method makes fail and toss go towards their targets*/
166 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value launchBullet(Sprite[brackets are typically used to declare, initialize and index (indicate which element of) arrays]brackets are typically used to declare, initialize and index (indicate which element of) arrays thrown, Sprite name, Sprite pic1)
167 {open braces start code blocks and must be matched with a close brace
168 reclaimUsedBullets(thrown);
169 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 k=this assignment operator makes the left side equal to the right side0; k<thrown.length; k++this is the increment operator, which increases the variable by 1)
170 {open braces start code blocks and must be matched with a close brace
171 ifif executes the next statement only if the condition in parenthesis evaluates to true(thrown[brackets are typically used to declare, initialize and index (indicate which element of) arraysk]brackets are typically used to declare, initialize and index (indicate which element of) arrays.isVisible()==this is the comparison operator which evaluates to true if both sides are the samefalsefalse is a value for the boolean type and means not true)
172 {open braces start code blocks and must be matched with a close brace
173 Point2D.Double pic1Location=this assignment operator makes the left side equal to the right sidepic1.getLocation();
174 Point2D.Double nameLocation=this assignment operator makes the left side equal to the right sidename.getLocation();
175 doubledouble is the type for numbers that can contain decimal fractions angle=this assignment operator makes the left side equal to the right sideMath.atan2(pic1Location.y-nameLocation.y, pic1Location.x-nameLocation.x);
176 ProjectileTracker tracker=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor ProjectileTracker(0, 0.1);
177 tracker.setVelocityDirection(angle);
178 thrown[brackets are typically used to declare, initialize and index (indicate which element of) arraysk]brackets are typically used to declare, initialize and index (indicate which element of) arrays.setLocation(name.getLocation());
179 thrown[brackets are typically used to declare, initialize and index (indicate which element of) arraysk]brackets are typically used to declare, initialize and index (indicate which element of) arrays.setTracker(tracker);
180 thrown[brackets are typically used to declare, initialize and index (indicate which element of) arraysk]brackets are typically used to declare, initialize and index (indicate which element of) arrays.setVisible(truetrue is the boolean value that is the opposite of false);
181 returnreturn means to provide the result of the method and/or cease execution of the method immediately;
182 }close braces end code blocks and must match an earlier open brace
183 }close braces end code blocks and must match an earlier open brace
184 }close braces end code blocks and must match an earlier open brace
185 /**This method reclaims toss and fail once they are no longer visible*/
186 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value reclaimUsedBullets(Sprite[brackets are typically used to declare, initialize and index (indicate which element of) arrays]brackets are typically used to declare, initialize and index (indicate which element of) arrays thrown)
187 {open braces start code blocks and must be matched with a close brace
188 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 k=this assignment operator makes the left side equal to the right side0; k<thrown.length; k++this is the increment operator, which increases the variable by 1)
189 {open braces start code blocks and must be matched with a close brace
190 ifif executes the next statement only if the condition in parenthesis evaluates to true(isOffScreen(thrown[brackets are typically used to declare, initialize and index (indicate which element of) arraysk]brackets are typically used to declare, initialize and index (indicate which element of) arrays))
191 {open braces start code blocks and must be matched with a close brace
192 thrown[brackets are typically used to declare, initialize and index (indicate which element of) arraysk]brackets are typically used to declare, initialize and index (indicate which element of) arrays.setVisible(falsefalse is a value for the boolean type and means not true);
193 }close braces end code blocks and must match an earlier open brace
194 }close braces end code blocks and must match an earlier open brace
195 }close braces end code blocks and must match an earlier open brace
196 /**This method helps determine ifif executes the next statement only if the condition in parenthesis evaluates to true toss or fail is off the screen or not*/
197 privateprivate is used to restrict access to the current class only booleanboolean is a type that is either true or false isOffScreen(Sprite sprite)
198 {open braces start code blocks and must be matched with a close brace
199 ifif executes the next statement only if the condition in parenthesis evaluates to true(sprite.getLocation().x-sprite.getBounds2D().getWidth()/2>1 ||this is boolean or, meaning if either or both are true then the result is true
200 sprite.getLocation().y-sprite.getBounds2D().getHeight()/2>1 ||this is boolean or, meaning if either or both are true then the result is true
201 sprite.getLocation().x+adds two numbers together or concatenates Strings togethersprite.getBounds2D().getWidth()/2<0 ||this is boolean or, meaning if either or both are true then the result is true
202 sprite.getLocation().y+adds two numbers together or concatenates Strings togethersprite.getBounds2D().getHeight()/2<0)
203 {open braces start code blocks and must be matched with a close brace
204 returnreturn means to provide the result of the method and/or cease execution of the method immediately truetrue is the boolean value that is the opposite of false;
205 }close braces end code blocks and must match an earlier open brace
206 returnreturn means to provide the result of the method and/or cease execution of the method immediately falsefalse is a value for the boolean type and means not true;
207 }close braces end code blocks and must match an earlier open brace
208 /**This method tells determines when to start the method launchBullet*/
209 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value handleKK(Sprite[brackets are typically used to declare, initialize and index (indicate which element of) arrays]brackets are typically used to declare, initialize and index (indicate which element of) arrays thrown, Sprite pic1, Sprite name)
210 {open braces start code blocks and must be matched with a close brace
211 Point2D.Double position=this assignment operator makes the left side equal to the right sidegetPlayer().getMouse().getLocation();
212 pic1.setLocation(pic1.getLocation().x, position.y);
213 ifif executes the next statement only if the condition in parenthesis evaluates to true(getPlayer().getMouse().getClickLocation()!=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)
214 {open braces start code blocks and must be matched with a close brace
215 launchBullet(thrown, pic1, name);
216 }close braces end code blocks and must match an earlier open brace
217 }close braces end code blocks and must match an earlier open brace
218 /**This method determines what happens when kid intersects fail*/
219 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value kidIntersection()
220 {open braces start code blocks and must be matched with a close brace
221 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 k=this assignment operator makes the left side equal to the right side0; k<fail.length; k++this is the increment operator, which increases the variable by 1)
222 {open braces start code blocks and must be matched with a close brace
223 ifif executes the next statement only if the condition in parenthesis evaluates to true(kid.intersects(fail[brackets are typically used to declare, initialize and index (indicate which element of) arraysk]brackets are typically used to declare, initialize and index (indicate which element of) arrays)&this performs a bit-wise and (not the same as boolean and which is &&)&this performs a bit-wise and (not the same as boolean and which is &&) fail[brackets are typically used to declare, initialize and index (indicate which element of) arraysk]brackets are typically used to declare, initialize and index (indicate which element of) arrays.isVisible())
224 {open braces start code blocks and must be matched with a close brace
225 fail[brackets are typically used to declare, initialize and index (indicate which element of) arraysk]brackets are typically used to declare, initialize and index (indicate which element of) arrays.setVisible(falsefalse is a value for the boolean type and means not true);
226 updateGPA--this is the decrement operator, which decreases the variable by 1;
227 refreshUpdateGPA();
228 lives--this is the decrement operator, which decreases the variable by 1;
229 refreshLives();
230 }close braces end code blocks and must match an earlier open brace
231 }close braces end code blocks and must match an earlier open brace
232 }close braces end code blocks and must match an earlier open brace
233 /**This method determines what happens when kaufman intersects toss*/
234 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value kaufmanIntersection()
235 {open braces start code blocks and must be matched with a close brace
236 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 k=this assignment operator makes the left side equal to the right side0; k<toss.length; k++this is the increment operator, which increases the variable by 1)
237 {open braces start code blocks and must be matched with a close brace
238 ifif executes the next statement only if the condition in parenthesis evaluates to true(kaufman.intersects(toss[brackets are typically used to declare, initialize and index (indicate which element of) arraysk]brackets are typically used to declare, initialize and index (indicate which element of) arrays)&this performs a bit-wise and (not the same as boolean and which is &&)&this performs a bit-wise and (not the same as boolean and which is &&) toss[brackets are typically used to declare, initialize and index (indicate which element of) arraysk]brackets are typically used to declare, initialize and index (indicate which element of) arrays.isVisible())
239 {open braces start code blocks and must be matched with a close brace
240 toss[brackets are typically used to declare, initialize and index (indicate which element of) arraysk]brackets are typically used to declare, initialize and index (indicate which element of) arrays.setVisible(falsefalse is a value for the boolean type and means not true);
241 updateGPA++this is the increment operator, which increases the variable by 1;
242 refreshUpdateGPA();
243 }close braces end code blocks and must match an earlier open brace
244 }close braces end code blocks and must match an earlier open brace
245 }close braces end code blocks and must match an earlier open brace
246 /**This method determines what happens when lives gets to or below 0*/
247 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value affectLives()
248 {open braces start code blocks and must be matched with a close brace
249 ifif executes the next statement only if the condition in parenthesis evaluates to true(lives<=this evaluates to true if the left side is not more than the right side0)
250 {open braces start code blocks and must be matched with a close brace
251 canvas.addSprite(lose);
252 }close braces end code blocks and must match an earlier open brace
253
254 }close braces end code blocks and must match an earlier open brace
255 /**This method determines what happens when gpa gets to or above 4*/
256 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value affectGPA()
257 {open braces start code blocks and must be matched with a close brace
258 ifif executes the next statement only if the condition in parenthesis evaluates to true(updateGPA>=this evaluates to true if the left side is not less than the right side4)
259 {open braces start code blocks and must be matched with a close brace
260 canvas.addSprite(diploma);
261 canvas.addSprite(win);
262 }close braces end code blocks and must match an earlier open brace
263
264 }close braces end code blocks and must match an earlier open brace
265 /**This method determines what happens when kaufman gets below 0.0 or above 1.0*/
266 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value kaufmanLocation()
267 {open braces start code blocks and must be matched with a close brace
268 ifif executes the next statement only if the condition in parenthesis evaluates to true(kaufman.getLocation().y<=this evaluates to true if the left side is not more than the right side0.0)
269 {open braces start code blocks and must be matched with a close brace
270 kaufman.setLocation(kaufman.getLocation().x, 1.0);
271 }close braces end code blocks and must match an earlier open brace
272 ifif executes the next statement only if the condition in parenthesis evaluates to true(kaufman.getLocation().y>=this evaluates to true if the left side is not less than the right side1.0)
273 {open braces start code blocks and must be matched with a close brace
274 kaufman.setLocation(kaufman.getLocation().x, 0.0);
275 }close braces end code blocks and must match an earlier open brace
276 }close braces end code blocks and must match an earlier open brace
277 /**This method determines kaufmans velocity and what happens ifif executes the next statement only if the condition in parenthesis evaluates to true the velocity is too slow or too fast*/
278 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value kaufmanDirection()
279 {open braces start code blocks and must be matched with a close brace
280 Point2D.Double direction=this assignment operator makes the left side equal to the right sidetracker.getVelocity();
281 direction.y+=this increases the variable on the left by the value on the rightrandom.nextDouble()*0.18-0.09;
282 ifif executes the next statement only if the condition in parenthesis evaluates to true(direction.y<-0.5)
283 {open braces start code blocks and must be matched with a close brace
284 direction.y=this assignment operator makes the left side equal to the right side-0.5;
285 }close braces end code blocks and must match an earlier open brace
286 ifif executes the next statement only if the condition in parenthesis evaluates to true(direction.y>0.5)
287 {open braces start code blocks and must be matched with a close brace
288 direction.y=this assignment operator makes the left side equal to the right side0.5;
289 }close braces end code blocks and must match an earlier open brace
290
291 tracker.setVelocity(direction);
292 }close braces end code blocks and must match an earlier open brace
293 /**This method determines what happens when the game is started*/
294 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value stepOne()
295 {open braces start code blocks and must be matched with a close brace
296 ifif executes the next statement only if the condition in parenthesis evaluates to true(updateGPA<4 &this performs a bit-wise and (not the same as boolean and which is &&)&this performs a bit-wise and (not the same as boolean and which is &&) lives>0)
297 {open braces start code blocks and must be matched with a close brace
298 handleKK(toss, kid, kaufman);
299 ifif executes the next statement only if the condition in parenthesis evaluates to true(getPlayer().getMouse().getClickLocation()!=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)
300 {open braces start code blocks and must be matched with a close brace
301 launchBullet(fail, kaufman, kid);
302 }close braces end code blocks and must match an earlier open brace
303
304 kaufmanDirection();
305 kaufmanLocation();
306 kidIntersection();
307 kaufmanIntersection();
308 affectLives();
309 affectGPA();
310 }close braces end code blocks and must match an earlier open brace
311 }close braces end code blocks and must match an earlier open brace
312 /**handle input and game events*/
313 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value advanceFrame(doubledouble is the type for numbers that can contain decimal fractions timePassed)
314 {open braces start code blocks and must be matched with a close brace
315 stepOne();
316 }close braces end code blocks and must match an earlier open brace
317 }close braces end code blocks and must match an earlier open brace
|