|
01 packagepackage is used to name the directory or folder a class is in GBell;
02 importimport means to make the classes and/or packages available in this program wiki.Wiki;
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 here.
09 * @authorthis is the Javadoc tag for documenting who created the source code Gbell
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 Dot_Removes_Shapes extendsextends means to customize or extend the functionality of a class GameLoop
12 {open braces start code blocks and must be matched with a close brace
13 /**an oval*/
14 privateprivate is used to restrict access to the current class only 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 oval;
15
16 /**a dot*/
17 privateprivate is used to restrict access to the current class only Sprite dot;
18
19 /**a tracker*/
20 privateprivate is used to restrict access to the current class only ProjectileTracker tracker;
21
22 /**sets up the game*/
23 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value startGame()
24 {open braces start code blocks and must be matched with a close brace
25 pauseToggle();
26 oval=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor Sprite[brackets are typically used to declare, initialize and index (indicate which element of) arrays100]brackets are typically used to declare, initialize and index (indicate which element of) arrays;
27 makeSprites();
28 addSprites();
29
30 }close braces end code blocks and must match an earlier open brace
31
32 /**makes the sprites*/
33 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value makeSprites()
34 {open braces start code blocks and must be matched with a close brace
35 dot=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor OvalSprite(1,1);
36 dot.setScale(.1);
37 dot.setColor(Color.GREEN);
38 canvas.addSprite(dot);
39
40 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 side0; i<oval.length; i++this is the increment operator, which increases the variable by 1)
41 {open braces start code blocks and must be matched with a close brace
42 oval[brackets are typically used to declare, initialize and index (indicate which element of) arraysi]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 PolygonSprite(random.nextInt(5)+adds two numbers together or concatenates Strings together3);
43 oval[brackets are typically used to declare, initialize and index (indicate which element of) arraysi]brackets are typically used to declare, initialize and index (indicate which element of) arrays.setScale(random.nextDouble());
44 oval[brackets are typically used to declare, initialize and index (indicate which element of) arraysi]brackets are typically used to declare, initialize and index (indicate which element of) arrays.setLocation(random.nextDouble(), random.nextDouble());
45 Color color=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor Color(random.nextFloat(), random.nextFloat(), random.nextFloat());
46 oval[brackets are typically used to declare, initialize and index (indicate which element of) arraysi]brackets are typically used to declare, initialize and index (indicate which element of) arrays.setColor(color);
47 }close braces end code blocks and must match an earlier open brace
48 }close braces end code blocks and must match an earlier open brace
49
50 /**adds the sprites to the screen*/
51 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value addSprites()
52 {open braces start code blocks and must be matched with a close brace
53 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 side0; i<oval.length; i++this is the increment operator, which increases the variable by 1)
54 {open braces start code blocks and must be matched with a close brace
55 canvas.addSprite(oval);
56 }close braces end code blocks and must match an earlier open brace
57 }close braces end code blocks and must match an earlier open brace
58
59 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)
60 {open braces start code blocks and must be matched with a close brace
61 Point2D.Double click=this assignment operator makes the left side equal to the right sidegetPlayer().getMouse().getClickLocation();
62 ifif executes the next statement only if the condition in parenthesis evaluates to true(click!=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)
63 {open braces start code blocks and must be matched with a close brace
64 /**ball follows mouse*/
65 }close braces end code blocks and must match an earlier open brace
66 handleCollisions();
67 trackerSetup();
68 }close braces end code blocks and must match an earlier open brace
69 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value handleCollisions()
70 {open braces start code blocks and must be matched with a close brace
71 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 side0; i<oval.length; i++this is the increment operator, which increases the variable by 1)
72 {open braces start code blocks and must be matched with a close brace
73 ifif executes the next statement only if the condition in parenthesis evaluates to true(dot.intersects(oval[brackets are typically used to declare, initialize and index (indicate which element of) arraysi]brackets are typically used to declare, initialize and index (indicate which element of) arrays))
74 {open braces start code blocks and must be matched with a close brace
75 canvas.removeSprite(oval[brackets are typically used to declare, initialize and index (indicate which element of) arraysi]brackets are typically used to declare, initialize and index (indicate which element of) arrays);
76 }close braces end code blocks and must match an earlier open brace
77 }close braces end code blocks and must match an earlier open brace
78 }close braces end code blocks and must match an earlier open brace
79
80 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value trackerSetup()
81 {open braces start code blocks and must be matched with a close brace
82 Point2D.Double direction=this assignment operator makes the left side equal to the right sidegetPlayer().getMouse().getLocation();
83 direction.x-=this decreases the variable on the left by the value on the rightdot.getLocation().x;
84 direction.y-=this decreases the variable on the left by the value on the rightdot.getLocation().y;
85 tracker=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor ProjectileTracker(direction);
86 dot.setTracker(tracker);
87 }close braces end code blocks and must match an earlier open brace
88 }close braces end code blocks and must match an earlier open brace
|