From FANG
|
01 packagepackage is used to name the directory or folder a class is in examples.levelSelect;
02 //start auto-imports
03 importimport means to make the classes and/or packages available in this program javax.swing.*;
04 //end auto-imports
05
06 importimport means to make the classes and/or packages available in this program fang2.attributes.*;
07 importimport means to make the classes and/or packages available in this program fang2.core.*;
08 importimport means to make the classes and/or packages available in this program fang2.sprites.*;
09 importimport means to make the classes and/or packages available in this program fang2.transformers.*;
10 importimport means to make the classes and/or packages available in this program java.awt.geom.*;
11
12 /**
13 * This classclass is a group of fields and methods used for making objects selects the level to
14 * move to.
15 * @authorthis is the Javadoc tag for documenting who created the source code Alex Park
16 * @authorthis is the Javadoc tag for documenting who created the source code modified by Jam when the
17 * FANG Engine was updated
18 */
19 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 LevelSelect
20 extendsextends means to customize or extend the functionality of a class Game
21 {open braces start code blocks and must be matched with a close brace
22 /**Sprite to click to go to level 1*/
23 privateprivate is used to restrict access to the current class only StringSprite level1;
24 /**Sprite to click to go to level 2*/
25 privateprivate is used to restrict access to the current class only StringSprite level2;
26
27 /**
28 * makes and adds the sprites.
29 */
30 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value setup()
31 {open braces start code blocks and must be matched with a close brace
32 makeSprites();
33 addSprites();
34 }close braces end code blocks and must match an earlier open brace
35
36 /**
37 *Adds sprites to the screen
38 */
39 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value addSprites()
40 {open braces start code blocks and must be matched with a close brace
41 addSprite(level1);
42 addSprite(level2);
43 }close braces end code blocks and must match an earlier open brace
44
45 /**
46 * Makes the sprites
47 */
48 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value makeSprites()
49 {open braces start code blocks and must be matched with a close brace
50 level1 =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor StringSprite("Click to go to Level 1");
51 level1.setLocation(0.5, 0.25);
52 level1.setScale(0.85);
53 level1.centerJustify();
54
55 level2 =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor StringSprite("Click to go to Level 2");
56 level2.setLocation(0.5, 0.75);
57 level2.setScale(0.85);
58 level2.centerJustify();
59 }close braces end code blocks and must match an earlier open brace
60 /**
61 * goes to the next level when clicked
62 */
63 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value advance()
64 {open braces start code blocks and must be matched with a close brace
65 handleClick();
66 }close braces end code blocks and must match an earlier open brace
67
68 /**
69 * Sets the variable levelNumber to a value
70 * when the screen is clicked
71 */
72 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value handleClick()
73 {open braces start code blocks and must be matched with a close brace
74 Location2D mouse =this assignment operator makes the left side equal to the right side getClick2D();
75 ifif executes the next statement only if the condition in parenthesis evaluates to true (mouse !=this is the not equals operator which evaluates to true if both sides are different nullnull is the value used to refer to a non-existant object)
76 {open braces start code blocks and must be matched with a close brace
77 ifif executes the next statement only if the condition in parenthesis evaluates to true(mouse.y >=this evaluates to true if the left side is not less than the right side 0 &this performs a bit-wise and (not the same as boolean and which is &&)&this performs a bit-wise and (not the same as boolean and which is &&) mouse.y <=this evaluates to true if the left side is not more than the right side 0.5)
78 {open braces start code blocks and must be matched with a close brace
79 addGame(newnew is used to create objects by calling the constructor Level1("You are in Level 1\nClick to go back"));
80 finishGame();
81 }close braces end code blocks and must match an earlier open brace
82 elseelse is what happens when the if condition is false ifif executes the next statement only if the condition in parenthesis evaluates to true(mouse.y <=this evaluates to true if the left side is not more than the right side 1 &this performs a bit-wise and (not the same as boolean and which is &&)&this performs a bit-wise and (not the same as boolean and which is &&) mouse.y >=this evaluates to true if the left side is not less than the right side 0.5)
83 {open braces start code blocks and must be matched with a close brace
84 addGame(newnew is used to create objects by calling the constructor Level1("You are in Level 2\nClick to go back"));
85 finishGame();
86 }close braces end code blocks and must match an earlier open brace
87 }close braces end code blocks and must match an earlier open brace
88 }close braces end code blocks and must match an earlier open brace
89 }close braces end code blocks and must match an earlier open brace
90
91 //Uploaded on Sat Sep 19 13:58:07 EDT 2009
|
Download/View examples/levelSelect/LevelSelect.java