From ggc
|
01 packagepackage is used to name the directory or folder a class is in intro;
02
03 importimport means to make the classes and/or packages available in this program fang.*;
04 importimport means to make the classes and/or packages available in this program java.awt.*;
05 importimport means to make the classes and/or packages available in this program java.awt.geom.*;
06
07 /**
08 * All about my game.
09 * @authorthis is the Javadoc tag for documenting who created the source code My Name Here
10 */
11 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 Bounce extendsextends means to customize or extend the functionality of a class Game
12 {open braces start code blocks and must be matched with a close brace
13 privateprivate is used to restrict access to the current class only OutlineSprite boundary;
14 privateprivate is used to restrict access to the current class only OvalSprite ball;
15 privateprivate is used to restrict access to the current class only ProjectileTransformer projectile;
16
17 /**sets up the game*/
18 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value setup()
19 {open braces start code blocks and must be matched with a close brace
20 makeAndAddBoundary();
21
22 makeAndAddBall();
23
24 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);
25 ball.setTracker(projectile);
26 }close braces end code blocks and must match an earlier open brace
27
28 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value makeAndAddBall()
29 {open braces start code blocks and must be matched with a close brace
30 ball=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);
31 ball.setLocation(0.5, 0.5);
32 addSprite(ball);
33 }close braces end code blocks and must match an earlier open brace
34
35 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value makeAndAddBoundary()
36 {open braces start code blocks and must be matched with a close brace
37 boundary=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));
38 boundary.setSize(0.9);
39 boundary.setLineThickness(0.2);
40 boundary.setLocation(0.5, 0.5);
41 addSprite(boundary);
42 }close braces end code blocks and must match an earlier open brace
43
44 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value handleCollisions()
45 {open braces start code blocks and must be matched with a close brace
46 ball.bounceOffOf(boundary);
47 }close braces end code blocks and must match an earlier open brace
48
49 /**handle input and game events*/
50 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value advance()
51 {open braces start code blocks and must be matched with a close brace
52 handleCollisions();
53 }close braces end code blocks and must match an earlier open brace
54
55 }close braces end code blocks and must match an earlier open brace
|
Download/View intro/Bounce.java