From ggc
|
01 packagepackage is used to name the directory or folder a class is in jam;
02
03 importimport means to make the classes and/or packages available in this program fang.*;
04 importimport means to make the classes and/or packages available in this program java.awt.geom.*;
05 importimport means to make the classes and/or packages available in this program wiki.Wiki;
06 /**
07 * All about my classclass is a group of fields and methods used for making objects here.
08 * @authorthis is the Javadoc tag for documenting who created the source code Jam Jenkins
09 */
10 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 Level2 extendsextends means to customize or extend the functionality of a class GameLevel
11 {open braces start code blocks and must be matched with a close brace
12 privateprivate is used to restrict access to the current class only Sprite oval;
13 privateprivate is used to restrict access to the current class only StringSprite goldDisplay;
14 privateprivate is used to restrict access to the current class only GameState state;
15
16 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value startLevel()
17 {open braces start code blocks and must be matched with a close brace
18 oval=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor RectangleSprite(1, 1);
19 oval.setScale(0.5);
20 oval.setLocation(0.5, 0.5);
21 canvas.addSprite(oval);
22 canvas.addSprite(state.getGoldSprite());
23 canvas.addSprite(state.getLifeSprite());
24 }close braces end code blocks and must match an earlier open brace
25
26 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value setGameState(GameState state)
27 {open braces start code blocks and must be matched with a close brace
28 thisthis means the current object (the implicit parameter).state=this assignment operator makes the left side equal to the right sidestate;
29 }close braces end code blocks and must match an earlier open brace
30
31
32 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)
33 {open braces start code blocks and must be matched with a close brace
34 Point2D.Double clickLocation=this assignment operator makes the left side equal to the right sidegetPlayer().getMouse().getClickLocation();
35 ifif executes the next statement only if the condition in parenthesis evaluates to true(clickLocation!=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)
36 {open braces start code blocks and must be matched with a close brace
37 Level1 level1=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor Level1();
38 state.setGold(state.getGold()+adds two numbers together or concatenates Strings together1);
39 state.setLife(state.getLife()-1);
40 level1.setGameState(state);
41 setNextLevel(level1);
42 finishLevel();
43 }close braces end code blocks and must match an earlier open brace
44 }close braces end code blocks and must match an earlier open brace
45
46 }close braces end code blocks and must match an earlier open brace
|
Download/View jam/Level2.java