From ggc
|
01 packagepackage is used to name the directory or folder a class is in grid;
02
03 importimport means to make the classes and/or packages available in this program wiki.Wiki;
04 importimport means to make the classes and/or packages available in this program fang.*;
05 importimport means to make the classes and/or packages available in this program java.awt.*;
06 importimport means to make the classes and/or packages available in this program java.awt.geom.*;
07
08 /**
09 * All about my game here.
10 * @authorthis is the Javadoc tag for documenting who created the source code Jam Jenkins
11 */
12 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 ShowGrid extendsextends means to customize or extend the functionality of a class GameLoop
13 {open braces start code blocks and must be matched with a close brace
14 /**an oval*/
15 privateprivate is used to restrict access to the current class only Sprite oval;
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 startGame()
19 {open braces start code blocks and must be matched with a close brace
20 makeSprites();
21 addSprites();
22 }close braces end code blocks and must match an earlier open brace
23
24 /**makes the sprites*/
25 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value makeSprites()
26 {open braces start code blocks and must be matched with a close brace
27 oval=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor Grid(5, 5, 0.05);
28 oval.setScale(0.75);
29 oval.setLocation(0.5, 0.5);
30 }close braces end code blocks and must match an earlier open brace
31
32 /**adds the sprites to the screen*/
33 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value addSprites()
34 {open braces start code blocks and must be matched with a close brace
35 canvas.addSprite(oval);
36 }close braces end code blocks and must match an earlier open brace
37
38 /**handle input and game events*/
39 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)
40 {open braces start code blocks and must be matched with a close brace
41 oval.setLocation(getPlayer().getMouse().getLocation());
42 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)
43 {open braces start code blocks and must be matched with a close brace
44 oval.setScale(random.nextDouble());
45 }close braces end code blocks and must match an earlier open brace
46 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'r')
47 {open braces start code blocks and must be matched with a close brace
48 oval.setColor(Color.RED);
49 }close braces end code blocks and must match an earlier open brace
50 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')
51 {open braces start code blocks and must be matched with a close brace
52 oval.setColor(Color.WHITE);
53 }close braces end code blocks and must match an earlier open brace
54 }close braces end code blocks and must match an earlier open brace
55 }close braces end code blocks and must match an earlier open brace
|
Download/View grid/ShowGrid.java