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 BlinkExample 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 OutlineSprite outline;
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 PolygonSprite poly=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor PolygonSprite(5);
19 outline=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor OutlineSprite(poly);
20 outline.setSize(0.5);
21 outline.setLineThickness(0.1);
22 outline.setLocation(0.5, 0.5);
23 addSprite(outline);
24
25 schedule(newnew is used to create objects by calling the constructor Blinker(), 1);
26 }close braces end code blocks and must match an earlier open brace
27
28 classclass is a group of fields and methods used for making objects Blinker extendsextends means to customize or extend the functionality of a class TimedAction
29 {open braces start code blocks and must be matched with a close brace
30 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value act()
31 {open braces start code blocks and must be matched with a close brace
32 booleanboolean is a type that is either true or false vis=this assignment operator makes the left side equal to the right sideoutline.isVisible();
33 outline.setVisible(!this is the not operator, which changes true to false and false to truevis);
34 schedule(thisthis means the current object (the implicit parameter), 1);
35 }close braces end code blocks and must match an earlier open brace
36 }close braces end code blocks and must match an earlier open brace
37
38 /**handle input and game events*/
39 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value advance()
40 {open braces start code blocks and must be matched with a close brace}close braces end code blocks and must match an earlier open brace
41 }close braces end code blocks and must match an earlier open brace
|
Download/View intro/BlinkExample.java