From ggc
|
01 packagepackage is used to name the directory or folder a class is in intro;
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.*;
05 importimport means to make the classes and/or packages available in this program java.awt.geom.*;
06
07 /**
08 * All about my game.
09 * @authorthis is the Javadoc tag for documenting who created the source code My Name Here
10 */
11 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 DropIt extendsextends means to customize or extend the functionality of a class Game
12 {open braces start code blocks and must be matched with a close brace
13 privateprivate is used to restrict access to the current class only Sprite dot;
14
15 /**sets up the game*/
16 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value setup()
17 {open braces start code blocks and must be matched with a close brace
18 dot=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor OvalSprite(0.1, 0.1);
19 dot.setLocation(0.5, 0.1);
20 addSprite(dot);
21 }close braces end code blocks and must match an earlier open brace
22
23 /**handle input and game events*/
24 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value advance()
25 {open braces start code blocks and must be matched with a close brace
26 ifif executes the next statement only if the condition in parenthesis evaluates to true(dot.getY()<0.5)
27 dot.translate(0.0, 0.01);
28 elseelse is what happens when the if condition is false
29 dot.translate(0.0, 0.02);
30 }close braces end code blocks and must match an earlier open brace
31 }close braces end code blocks and must match an earlier open brace
|
Download/View intro/DropIt.java