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 * @authornull 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 ClickEvenOrOddExample 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 }close braces end code blocks and must match an earlier open brace
27
28 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value doStage2Interaction()
29 {open braces start code blocks and must be matched with a close brace
30 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);
31 Point2D.Double location=this assignment operator makes the left side equal to the right sidegetPlayer().getMouse().getClickLocation();
32 poly.setLocation(location);
33 poly.setScale(0.2);
34 canvas.addSprite(poly);
35 }close braces end code blocks and must match an earlier open brace
36
37 /**handle input and game events*/
38 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)
39 {open braces start code blocks and must be matched with a close brace
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 clickCount=this assignment operator makes the left side equal to the right sideclickCount+adds two numbers together or concatenates Strings together1;
43 ifif executes the next statement only if the condition in parenthesis evaluates to true(clickCount%this divides the left side by the right side and evaluates to the remainder2==this is the comparison operator which evaluates to true if both sides are the same0)
44 {open braces start code blocks and must be matched with a close brace
45 doStage1Interaction();
46 }close braces end code blocks and must match an earlier open brace
47 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 divides the left side by the right side and evaluates to the remainder2==this is the comparison operator which evaluates to true if both sides are the same1)
48 {open braces start code blocks and must be matched with a close brace
49 doStage2Interaction();
50 }close braces end code blocks and must match an earlier open brace
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
|
Download/View ClickEvenOrOddExample.java