From ggc
|
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 ImageExampleSummer 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 ImageSprite 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 }close braces end code blocks and must match an earlier open brace
20
21 /**makes the sprites*/
22 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value makeSprites()
23 {open braces start code blocks and must be matched with a close brace
24 oval=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor ImageSprite("Jam.jpg");
25 oval.setImage("Dog.gif");
26 oval.setScale(0.75);
27 oval.setLocation(0.5, 0.5);
28 }close braces end code blocks and must match an earlier open brace
29
30 /**adds the sprites to the screen*/
31 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value addSprites()
32 {open braces start code blocks and must be matched with a close brace
33 canvas.addSprite(oval);
34 }close braces end code blocks and must match an earlier open brace
35
36 /**handle input and game events*/
37 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)
38 {open braces start code blocks and must be matched with a close brace
39 oval.setLocation(getPlayer().getMouse().getLocation());
40 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)
41 {open braces start code blocks and must be matched with a close brace
42 oval.setScale(random.nextDouble());
43 oval.setImage("Jam.jpg");
44 }close braces end code blocks and must match an earlier open brace
45 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')
46 {open braces start code blocks and must be matched with a close brace
47 oval.setColor(Color.RED);
48 }close braces end code blocks and must match an earlier open brace
49 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')
50 {open braces start code blocks and must be matched with a close brace
51 oval.setColor(Color.WHITE);
52 }close braces end code blocks and must match an earlier open brace
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
|
Download/View ImageExampleSummer.java