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 ClickContextExample 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 privateprivate is used to restrict access to the current class only intint is the type for whole numbers and it is short for integer clickCount;
12
13 /**sets up the game*/
14 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value startGame()
15 {open braces start code blocks and must be matched with a close brace
16 clickCount=this assignment operator makes the left side equal to the right side0;
17 }close braces end code blocks and must match an earlier open brace
18
19 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value doStage1Interaction()
20 {open braces start code blocks and must be matched with a close brace
21 PolygonSprite poly=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor PolygonSprite(3);
22 Point2D.Double location=this assignment operator makes the left side equal to the right sidegetPlayer().getMouse().getClickLocation();
23 poly.setLocation(location);
24 poly.setScale(0.2);
25 canvas.addSprite(poly);
26 clickCount=this assignment operator makes the left side equal to the right side1;
27 }close braces end code blocks and must match an earlier open brace
28
29 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value doStage2Interaction()
30 {open braces start code blocks and must be matched with a close brace
31 PolygonSprite poly=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor PolygonSprite(4);
32 Point2D.Double location=this assignment operator makes the left side equal to the right sidegetPlayer().getMouse().getClickLocation();
33 poly.setLocation(location);
34 poly.setScale(0.2);
35 canvas.addSprite(poly);
36 clickCount=this assignment operator makes the left side equal to the right side0;
37 }close braces end code blocks and must match an earlier open brace
38
39 /**handle input and game events*/
40 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)
41 {open braces start code blocks and must be matched with a close brace
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 ifif executes the next statement only if the condition in parenthesis evaluates to true(clickCount==this is the comparison operator which evaluates to true if both sides are the same0)
45 {open braces start code blocks and must be matched with a close brace
46 doStage1Interaction();
47 }close braces end code blocks and must match an earlier open brace
48 elseelse is what happens when the if condition is false ifif executes the next statement only if the condition in parenthesis evaluates to true(clickCount==this is the comparison operator which evaluates to true if both sides are the same1)
49 {open braces start code blocks and must be matched with a close brace
50 doStage2Interaction();
51 }close braces end code blocks and must match an earlier open brace
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 ClickContextExample.java