|
001 packagepackage is used to name the directory or folder a class is in WilliamAnderson;
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
008 /**
009 * All about my game here.
010 * @authorthis is the Javadoc tag for documenting who created the source code Wanderso
011 */
012 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 Asteroids extendsextends means to customize or extend the functionality of a class GameLoop
013 {open braces start code blocks and must be matched with a close brace
014 privateprivate is used to restrict access to the current class only Sprite lwall, rwall, floor, twall, roid1, roid2;
015 privateprivate is used to restrict access to the current class only Sprite roid3, roid4, roid5, shippy, bullet;
016 privateprivate is used to restrict access to the current class only ProjectileTracker tracker, tracker2, tracker3, tracker4, tracker5, btracker;
017
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 intint is the type for whole numbers and it is short for integer score, level, lives;
020 privateprivate is used to restrict access to the current class only StringSprite scoreSprite, livesS, gameOver;
021
022
023
024 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value startGame()
025 {open braces start code blocks and must be matched with a close brace
026
027 makeSprites();
028 addSprites();
029 makeWalls();
030 makeSounds();
031 level=this assignment operator makes the left side equal to the right side0;
032 lives=this assignment operator makes the left side equal to the right side10;
033 score=this assignment operator makes the left side equal to the right side0;
034
035
036 }close braces end code blocks and must match an earlier open brace
037
038 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value makeSprites()
039 {open braces start code blocks and must be matched with a close brace
040 background=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor ImageSprite("Wback.jpg");
041 background.setScale(1.5);
042 background.setLocation(.5,.5);
043
044 bullet=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor ImageSprite("Wbullet.gif");
045 bullet.setScale(.25);
046
047 roid1=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor ImageSprite("Roid1.gif");
048 roid1.setScale(.25);
049 roid1.setLocation(random.nextDouble(),random.nextDouble());
050
051
052
053 roid2=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor ImageSprite("Roid3.gif");
054 roid2.setScale(.25);
055 roid2.setLocation(random.nextDouble(),random.nextDouble());
056
057
058
059
060 roid3=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor ImageSprite("Roid4.gif");
061 roid3.setScale(.25);
062 roid3.setLocation(random.nextDouble(),random.nextDouble());
063
064
065 roid4=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor ImageSprite("Roid2.gif");
066 roid4.setScale(.25);
067 roid4.setLocation(random.nextDouble(),random.nextDouble());
068
069
070
071 roid5=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor ImageSprite("Roid1.gif");
072 roid5.setScale(.25);
073 roid5.setLocation(random.nextDouble(),random.nextDouble());
074
075
076
077 shippy=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor ImageSprite("Shippy.gif");
078 shippy.setScale(.25);
079 shippy.setLocation(.5,.5);
080
081
082
083 tracker=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor ProjectileTracker(.10,random.nextDouble());
084 tracker2=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor ProjectileTracker(.10,random.nextDouble());
085 tracker3=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor ProjectileTracker(.10,random.nextDouble());
086 tracker4=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor ProjectileTracker(.10,random.nextDouble());
087 tracker5=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor ProjectileTracker(.10,random.nextDouble());
088
089
090
091 roid1.setTracker(tracker);
092 roid2.setTracker(tracker2);
093 roid3.setTracker(tracker3);
094 roid4.setTracker(tracker4);
095 roid5.setTracker(tracker5);
096
097
098
099
100 scoreSprite=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor StringSprite("Score: "+adds two numbers together or concatenates Strings togetherscore);
101 scoreSprite.setScale(.2);
102 scoreSprite.setLocation(.8,.9);
103 scoreSprite.setColor(Color.BLACK);
104
105 livesS=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor StringSprite("Lives: 3");
106 livesS.setScale(.2);
107 livesS.setLocation(.2,.9);
108 livesS.setColor(Color.BLACK);
109
110 gameOver=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor StringSprite("Game Over");
111 gameOver.setScale(.5);
112 gameOver.setLocation(.5,.5);
113 gameOver.setColor(Color.RED);
114
115
116
117
118
119 }close braces end code blocks and must match an earlier open brace
120 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value addSprites()
121 {open braces start code blocks and must be matched with a close brace
122 canvas.addSprite(background, roid1, roid2, roid3, roid4, roid5, shippy, scoreSprite, livesS);
123
124 }close braces end code blocks and must match an earlier open brace
125
126
127
128 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value makeSounds()
129 {open braces start code blocks and must be matched with a close brace}close braces end code blocks and must match an earlier open brace
130
131
132
133
134 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value makeWalls()
135 {open braces start code blocks and must be matched with a close brace
136 lwall=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor RectangleSprite(1, 40);
137 lwall.setLocation(0, 0.5);
138 lwall.setScale(1);
139 lwall.setColor(Color.BLUE);
140 canvas.addSprite(lwall);
141 rwall=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor RectangleSprite(1, 40);
142 rwall.setLocation(1, 0.5);
143 rwall.setScale(1);
144 rwall.setColor(Color.BLUE);
145 canvas.addSprite(rwall);
146 twall=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor RectangleSprite(40, 1);
147 twall.setLocation(0.5, 0);
148 twall.setScale(1);
149 twall.setColor(Color.BLUE);
150 canvas.addSprite(twall);
151 floor=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor RectangleSprite(40, 1);
152 floor.setLocation(0.5, 1);
153 floor.setScale(1);
154 floor.setColor(Color.BLUE);
155 canvas.addSprite(floor);
156 }close braces end code blocks and must match an earlier open brace
157
158 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value roidIntersects()
159 {open braces start code blocks and must be matched with a close brace
160
161 ifif executes the next statement only if the condition in parenthesis evaluates to true(rwall.intersects(roid1))
162 {open braces start code blocks and must be matched with a close brace
163 doubledouble is the type for numbers that can contain decimal fractions normal=this assignment operator makes the left side equal to the right sideSprite.getNormalVector(rwall.getShape(), roid1.getShape());
164 tracker.bounce(normal);
165 }close braces end code blocks and must match an earlier open brace
166 ifif executes the next statement only if the condition in parenthesis evaluates to true(lwall.intersects(roid1))
167 {open braces start code blocks and must be matched with a close brace
168 doubledouble is the type for numbers that can contain decimal fractions normal=this assignment operator makes the left side equal to the right sideSprite.getNormalVector(lwall.getShape(), roid1.getShape());
169 tracker.bounce(normal);
170
171 }close braces end code blocks and must match an earlier open brace
172
173 ifif executes the next statement only if the condition in parenthesis evaluates to true(twall.intersects(roid1))
174 {open braces start code blocks and must be matched with a close brace
175 doubledouble is the type for numbers that can contain decimal fractions normal=this assignment operator makes the left side equal to the right sideSprite.getNormalVector(twall.getShape(), roid1.getShape());
176 tracker.bounce(normal);
177
178 }close braces end code blocks and must match an earlier open brace
179
180 ifif executes the next statement only if the condition in parenthesis evaluates to true(floor.intersects(roid1))
181 {open braces start code blocks and must be matched with a close brace
182 doubledouble is the type for numbers that can contain decimal fractions normal=this assignment operator makes the left side equal to the right sideSprite.getNormalVector(floor.getShape(), roid1.getShape());
183 tracker.bounce(normal);
184 }close braces end code blocks and must match an earlier open brace
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199 ifif executes the next statement only if the condition in parenthesis evaluates to true(rwall.intersects(roid2))
200 {open braces start code blocks and must be matched with a close brace
201 doubledouble is the type for numbers that can contain decimal fractions normal=this assignment operator makes the left side equal to the right sideSprite.getNormalVector(rwall.getShape(), roid2.getShape());
202 tracker2.bounce(normal);
203 }close braces end code blocks and must match an earlier open brace
204 ifif executes the next statement only if the condition in parenthesis evaluates to true(lwall.intersects(roid2))
205 {open braces start code blocks and must be matched with a close brace
206 doubledouble is the type for numbers that can contain decimal fractions normal=this assignment operator makes the left side equal to the right sideSprite.getNormalVector(lwall.getShape(), roid2.getShape());
207 tracker2.bounce(normal);
208
209 }close braces end code blocks and must match an earlier open brace
210
211 ifif executes the next statement only if the condition in parenthesis evaluates to true(twall.intersects(roid2))
212 {open braces start code blocks and must be matched with a close brace
213 doubledouble is the type for numbers that can contain decimal fractions normal=this assignment operator makes the left side equal to the right sideSprite.getNormalVector(twall.getShape(), roid2.getShape());
214 tracker2.bounce(normal);
215
216 }close braces end code blocks and must match an earlier open brace
217
218 ifif executes the next statement only if the condition in parenthesis evaluates to true(floor.intersects(roid2))
219 {open braces start code blocks and must be matched with a close brace
220 doubledouble is the type for numbers that can contain decimal fractions normal=this assignment operator makes the left side equal to the right sideSprite.getNormalVector(floor.getShape(), roid2.getShape());
221 tracker2.bounce(normal);
222 }close braces end code blocks and must match an earlier open brace
223
224
225
226
227
228
229
230
231 ifif executes the next statement only if the condition in parenthesis evaluates to true(rwall.intersects(roid3))
232 {open braces start code blocks and must be matched with a close brace
233 doubledouble is the type for numbers that can contain decimal fractions normal=this assignment operator makes the left side equal to the right sideSprite.getNormalVector(rwall.getShape(), roid3.getShape());
234 tracker3.bounce(normal);
235 }close braces end code blocks and must match an earlier open brace
236 ifif executes the next statement only if the condition in parenthesis evaluates to true(lwall.intersects(roid3))
237 {open braces start code blocks and must be matched with a close brace
238 doubledouble is the type for numbers that can contain decimal fractions normal=this assignment operator makes the left side equal to the right sideSprite.getNormalVector(lwall.getShape(), roid3.getShape());
239 tracker3.bounce(normal);
240
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(twall.intersects(roid3))
244 {open braces start code blocks and must be matched with a close brace
245 doubledouble is the type for numbers that can contain decimal fractions normal=this assignment operator makes the left side equal to the right sideSprite.getNormalVector(twall.getShape(), roid3.getShape());
246 tracker3.bounce(normal);
247
248 }close braces end code blocks and must match an earlier open brace
249
250 ifif executes the next statement only if the condition in parenthesis evaluates to true(floor.intersects(roid3))
251 {open braces start code blocks and must be matched with a close brace
252 doubledouble is the type for numbers that can contain decimal fractions normal=this assignment operator makes the left side equal to the right sideSprite.getNormalVector(floor.getShape(), roid3.getShape());
253 tracker3.bounce(normal);
254 }close braces end code blocks and must match an earlier open brace
255
256
257
258
259
260
261
262 ifif executes the next statement only if the condition in parenthesis evaluates to true(rwall.intersects(roid4))
263 {open braces start code blocks and must be matched with a close brace
264 doubledouble is the type for numbers that can contain decimal fractions normal=this assignment operator makes the left side equal to the right sideSprite.getNormalVector(rwall.getShape(), roid4.getShape());
265 tracker4.bounce(normal);
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(lwall.intersects(roid4))
268 {open braces start code blocks and must be matched with a close brace
269 doubledouble is the type for numbers that can contain decimal fractions normal=this assignment operator makes the left side equal to the right sideSprite.getNormalVector(lwall.getShape(), roid4.getShape());
270 tracker4.bounce(normal);
271
272 }close braces end code blocks and must match an earlier open brace
273
274 ifif executes the next statement only if the condition in parenthesis evaluates to true(twall.intersects(roid4))
275 {open braces start code blocks and must be matched with a close brace
276 doubledouble is the type for numbers that can contain decimal fractions normal=this assignment operator makes the left side equal to the right sideSprite.getNormalVector(twall.getShape(), roid4.getShape());
277 tracker4.bounce(normal);
278
279 }close braces end code blocks and must match an earlier open brace
280
281 ifif executes the next statement only if the condition in parenthesis evaluates to true(floor.intersects(roid4))
282 {open braces start code blocks and must be matched with a close brace
283 doubledouble is the type for numbers that can contain decimal fractions normal=this assignment operator makes the left side equal to the right sideSprite.getNormalVector(floor.getShape(), roid4.getShape());
284 tracker4.bounce(normal);
285 }close braces end code blocks and must match an earlier open brace
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301 ifif executes the next statement only if the condition in parenthesis evaluates to true(rwall.intersects(roid5))
302 {open braces start code blocks and must be matched with a close brace
303 doubledouble is the type for numbers that can contain decimal fractions normal=this assignment operator makes the left side equal to the right sideSprite.getNormalVector(rwall.getShape(), roid5.getShape());
304 tracker5.bounce(normal);
305 }close braces end code blocks and must match an earlier open brace
306 ifif executes the next statement only if the condition in parenthesis evaluates to true(lwall.intersects(roid5))
307 {open braces start code blocks and must be matched with a close brace
308 doubledouble is the type for numbers that can contain decimal fractions normal=this assignment operator makes the left side equal to the right sideSprite.getNormalVector(lwall.getShape(), roid5.getShape());
309 tracker5.bounce(normal);
310
311 }close braces end code blocks and must match an earlier open brace
312
313 ifif executes the next statement only if the condition in parenthesis evaluates to true(twall.intersects(roid5))
314 {open braces start code blocks and must be matched with a close brace
315 doubledouble is the type for numbers that can contain decimal fractions normal=this assignment operator makes the left side equal to the right sideSprite.getNormalVector(twall.getShape(), roid5.getShape());
316 tracker5.bounce(normal);
317
318 }close braces end code blocks and must match an earlier open brace
319
320 ifif executes the next statement only if the condition in parenthesis evaluates to true(floor.intersects(roid5))
321 {open braces start code blocks and must be matched with a close brace
322 doubledouble is the type for numbers that can contain decimal fractions normal=this assignment operator makes the left side equal to the right sideSprite.getNormalVector(floor.getShape(), roid5.getShape());
323 tracker5.bounce(normal);
324 }close braces end code blocks and must match an earlier open brace
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346 ifif executes the next statement only if the condition in parenthesis evaluates to true(rwall.intersects(bullet))
347 {open braces start code blocks and must be matched with a close brace
348 canvas.removeSprite(bullet);
349 }close braces end code blocks and must match an earlier open brace
350 ifif executes the next statement only if the condition in parenthesis evaluates to true(lwall.intersects(bullet))
351 {open braces start code blocks and must be matched with a close brace
352 canvas.removeSprite(bullet);
353 }close braces end code blocks and must match an earlier open brace
354 ifif executes the next statement only if the condition in parenthesis evaluates to true(twall.intersects(bullet))
355 {open braces start code blocks and must be matched with a close brace
356 canvas.removeSprite(bullet);
357 }close braces end code blocks and must match an earlier open brace
358 ifif executes the next statement only if the condition in parenthesis evaluates to true(floor.intersects(bullet))
359 {open braces start code blocks and must be matched with a close brace
360 canvas.removeSprite(bullet);
361 }close braces end code blocks and must match an earlier open brace
362
363
364
365
366 }close braces end code blocks and must match an earlier open brace
367
368
369
370
371
372
373 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value updateScore()
374 {open braces start code blocks and must be matched with a close brace
375 scoreSprite.setText("Score: "+adds two numbers together or concatenates Strings togetherscore);
376 }close braces end code blocks and must match an earlier open brace
377
378 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value updateLives()
379 {open braces start code blocks and must be matched with a close brace
380 livesS.setText("Lives: "+adds two numbers together or concatenates Strings togetherlives);
381 }close braces end code blocks and must match an earlier open brace
382
383
384
385
386
387
388
389 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value roidRotate()
390 {open braces start code blocks and must be matched with a close brace}close braces end code blocks and must match an earlier open brace
391
392
393 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value shippyRotate()
394 {open braces start code blocks and must be matched with a close brace
395
396 shippy.rotate(-.3);
397 }close braces end code blocks and must match an earlier open brace
398
399 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value shippyRotate2()
400 {open braces start code blocks and must be matched with a close brace
401 shippy.rotate(.3);
402 }close braces end code blocks and must match an earlier open brace
403
404
405
406 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value makeBullets()
407 {open braces start code blocks and must be matched with a close brace
408
409 btracker=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor ProjectileTracker(.5,shippy.getRotation());
410 bullet.setTracker(btracker);
411
412 bullet.setLocation(shippy.getLocation());
413 canvas.addSprite(bullet);
414
415 }close braces end code blocks and must match an earlier open brace
416
417
418
419
420 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value score()
421 {open braces start code blocks and must be matched with a close brace
422 ifif executes the next statement only if the condition in parenthesis evaluates to true(bullet.intersects(roid1))
423 {open braces start code blocks and must be matched with a close brace
424
425
426 canvas.removeSprite(roid1);
427
428 score++this is the increment operator, which increases the variable by 1;
429 updateScore();
430 }close braces end code blocks and must match an earlier open brace
431
432
433
434 ifif executes the next statement only if the condition in parenthesis evaluates to true(bullet.intersects(roid2))
435 {open braces start code blocks and must be matched with a close brace
436
437 canvas.removeSprite(roid2);
438
439 score++this is the increment operator, which increases the variable by 1;
440 updateScore();
441 }close braces end code blocks and must match an earlier open brace
442
443
444
445
446 ifif executes the next statement only if the condition in parenthesis evaluates to true(bullet.intersects(roid3))
447 {open braces start code blocks and must be matched with a close brace
448
449
450
451 canvas.removeSprite(roid3);
452
453 score++this is the increment operator, which increases the variable by 1;
454 updateScore();
455 }close braces end code blocks and must match an earlier open brace
456
457
458
459
460
461 ifif executes the next statement only if the condition in parenthesis evaluates to true(bullet.intersects(roid4))
462 {open braces start code blocks and must be matched with a close brace
463
464
465 canvas.removeSprite(roid4);
466
467 score++this is the increment operator, which increases the variable by 1;
468 updateScore();
469 }close braces end code blocks and must match an earlier open brace
470
471
472
473
474
475 ifif executes the next statement only if the condition in parenthesis evaluates to true(bullet.intersects(roid5))
476 {open braces start code blocks and must be matched with a close brace
477
478
479 canvas.removeSprite(roid5);
480
481 score++this is the increment operator, which increases the variable by 1;
482 updateScore();
483 }close braces end code blocks and must match an earlier open brace
484
485
486
487
488
489
490
491
492 }close braces end code blocks and must match an earlier open brace
493
494 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value lifeCheck()
495 {open braces start code blocks and must be matched with a close brace
496 ifif executes the next statement only if the condition in parenthesis evaluates to true(shippy.intersects(roid1))
497 {open braces start code blocks and must be matched with a close brace
498
499 lives--this is the decrement operator, which decreases the variable by 1;
500 updateLives();
501 canvas.removeSprite(roid1);
502 }close braces end code blocks and must match an earlier open brace
503
504 ifif executes the next statement only if the condition in parenthesis evaluates to true(shippy.intersects(roid2))
505 {open braces start code blocks and must be matched with a close brace
506
507 lives--this is the decrement operator, which decreases the variable by 1;
508 updateLives();
509 canvas.removeSprite(roid2);
510 }close braces end code blocks and must match an earlier open brace
511
512 ifif executes the next statement only if the condition in parenthesis evaluates to true(shippy.intersects(roid3))
513 {open braces start code blocks and must be matched with a close brace
514
515 lives--this is the decrement operator, which decreases the variable by 1;
516 updateLives();
517 canvas.removeSprite(roid3);
518 }close braces end code blocks and must match an earlier open brace
519
520 ifif executes the next statement only if the condition in parenthesis evaluates to true(shippy.intersects(roid4))
521 {open braces start code blocks and must be matched with a close brace
522
523 lives--this is the decrement operator, which decreases the variable by 1;
524 updateLives();
525 canvas.removeSprite(roid4);
526 }close braces end code blocks and must match an earlier open brace
527
528 ifif executes the next statement only if the condition in parenthesis evaluates to true(shippy.intersects(roid5))
529 {open braces start code blocks and must be matched with a close brace
530
531 lives--this is the decrement operator, which decreases the variable by 1;
532 updateLives();
533 canvas.removeSprite(roid5);
534 }close braces end code blocks and must match an earlier open brace
535
536
537
538
539
540 }close braces end code blocks and must match an earlier open brace
541
542
543
544
545 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value isOver()
546 {open braces start code blocks and must be matched with a close brace
547 ifif executes the next statement only if the condition in parenthesis evaluates to true(lives==this is the comparison operator which evaluates to true if both sides are the same0)
548 {open braces start code blocks and must be matched with a close brace
549 canvas.removeSprite(bullet, roid1, roid2, roid3, roid4, roid5, shippy, scoreSprite, livesS);
550 canvas.addSprite(gameOver);
551 }close braces end code blocks and must match an earlier open brace
552
553 ifif executes the next statement only if the condition in parenthesis evaluates to true(score==this is the comparison operator which evaluates to true if both sides are the same10)
554 {open braces start code blocks and must be matched with a close brace
555 canvas.removeSprite(bullet, roid1, roid2, roid3, roid4, roid5, shippy, scoreSprite, livesS);
556 canvas.addSprite(gameOver);
557 }close braces end code blocks and must match an earlier open brace
558
559 }close braces end code blocks and must match an earlier open brace
560
561
562
563
564
565
566
567
568
569
570
571
572
573 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)
574 {open braces start code blocks and must be matched with a close brace
575
576 roidIntersects();
577 roidRotate();
578
579
580 ifif executes the next statement only if the condition in parenthesis evaluates to true(getPlayer().getKeyboard().getLastKey()==this is the comparison operator which evaluates to true if both sides are the same'w')
581 {open braces start code blocks and must be matched with a close brace
582 shippyRotate();
583 }close braces end code blocks and must match an earlier open brace
584
585
586 ifif executes the next statement only if the condition in parenthesis evaluates to true(getPlayer().getKeyboard().getLastKey()==this is the comparison operator which evaluates to true if both sides are the same'e')
587 {open braces start code blocks and must be matched with a close brace
588 shippyRotate2();
589 }close braces end code blocks and must match an earlier open brace
590
591
592 shippy.setLocation(getPlayer().getMouse().getLocation());
593
594
595
596 updateScore();
597 updateLives();
598
599 ifif executes the next statement only if the condition in parenthesis evaluates to true(getPlayer().getKeyboard().getLastKey()==this is the comparison operator which evaluates to true if both sides are the same't')
600 {open braces start code blocks and must be matched with a close brace
601 makeBullets();
602
603 }close braces end code blocks and must match an earlier open brace
604
605 score();
606 lifeCheck();
607 isOver();
608
609
610 }close braces end code blocks and must match an earlier open brace
611
612
613
614
615 }close braces end code blocks and must match an earlier open brace
|