|
01 importimport means to make the classes and/or packages available in this program fang.*;
02 importimport means to make the classes and/or packages available in this program java.awt.*;
03 importimport means to make the classes and/or packages available in this program java.awt.geom.*;
04
05 /**
06 * All about my game here.
07 * @authorthis is the Javadoc tag for documenting who created the source code Jam Jenkins
08 */
09 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 TwoDArray extendsextends means to customize or extend the functionality of a class GameLoop
10 {open braces start code blocks and must be matched with a close brace
11 /**an oval*/
12 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[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;
13
14 /**sets up the game*/
15 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value startGame()
16 {open braces start code blocks and must be matched with a close brace
17 makeSprites();
18 addSprites();
19 setHelpText("Click on the ovals to make them go away");
20 }close braces end code blocks and must match an earlier open brace
21
22 /**makes the sprites*/
23 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value makeSprites()
24 {open braces start code blocks and must be matched with a close brace
25 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) arrays3]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) arrays2]brackets are typically used to declare, initialize and index (indicate which element of) arrays;
26 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)
27 {open braces start code blocks and must be matched with a close brace
28 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 j=this assignment operator makes the left side equal to the right side0; j<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.length; j++this is the increment operator, which increases the variable by 1)
29 {open braces start code blocks and must be matched with a close brace
30 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[brackets are typically used to declare, initialize and index (indicate which element of) arraysj]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 OvalSprite(2, 1);
31 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[brackets are typically used to declare, initialize and index (indicate which element of) arraysj]brackets are typically used to declare, initialize and index (indicate which element of) arrays.setScale(0.25);
32 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[brackets are typically used to declare, initialize and index (indicate which element of) arraysj]brackets are typically used to declare, initialize and index (indicate which element of) arrays.setLocation(random.nextDouble(), random.nextDouble());
33 }close braces end code blocks and must match an earlier open brace
34 }close braces end code blocks and must match an earlier open brace
35 }close braces end code blocks and must match an earlier open brace
36
37 /**adds the sprites to the screen*/
38 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value addSprites()
39 {open braces start code blocks and must be matched with a close brace
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 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 j=this assignment operator makes the left side equal to the right side0; j<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.length; j++this is the increment operator, which increases the variable by 1)
43 {open braces start code blocks and must be matched with a close brace
44 canvas.addSprite(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[brackets are typically used to declare, initialize and index (indicate which element of) arraysj]brackets are typically used to declare, initialize and index (indicate which element of) arrays);
45 }close braces end code blocks and must match an earlier open brace
46 }close braces end code blocks and must match an earlier open brace
47 }close braces end code blocks and must match an earlier open brace
48
49 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value handleCollisions()
50 {open braces start code blocks and must be matched with a close brace
51 Point2D.Double click=this assignment operator makes the left side equal to the right sidegetPlayer().getMouse().getClickLocation();
52 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)
53 {open braces start code blocks and must be matched with a close brace
54 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)
55 {open braces start code blocks and must be matched with a close brace
56 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 j=this assignment operator makes the left side equal to the right side0; j<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.length; j++this is the increment operator, which increases the variable by 1)
57 {open braces start code blocks and must be matched with a close brace
58 ifif executes the next statement only if the condition in parenthesis evaluates to true(canvas.containsSprite(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[brackets are typically used to declare, initialize and index (indicate which element of) arraysj]brackets are typically used to declare, initialize and index (indicate which element of) arrays))
59 {open braces start code blocks and must be matched with a close brace
60 ifif executes the next statement only if the condition in parenthesis evaluates to true(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[brackets are typically used to declare, initialize and index (indicate which element of) arraysj]brackets are typically used to declare, initialize and index (indicate which element of) arrays.intersects(click))
61 {open braces start code blocks and must be matched with a close brace
62 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[brackets are typically used to declare, initialize and index (indicate which element of) arraysj]brackets are typically used to declare, initialize and index (indicate which element of) arrays);
63 }close braces end code blocks and must match an earlier open brace
64 }close braces end code blocks and must match an earlier open brace
65 }close braces end code blocks and must match an earlier open brace
66 }close braces end code blocks and must match an earlier open brace
67 }close braces end code blocks and must match an earlier open brace
68 }close braces end code blocks and must match an earlier open brace
69
70 /**handle input and game events*/
71 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)
72 {open braces start code blocks and must be matched with a close brace
73 handleCollisions();
74 }close braces end code blocks and must match an earlier open brace
75 }close braces end code blocks and must match an earlier open brace
|