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 wiki.Wiki;
04 importimport means to make the classes and/or packages available in this program fang.*;
05 importimport means to make the classes and/or packages available in this program java.awt.*;
06 importimport means to make the classes and/or packages available in this program java.awt.geom.*;
07 importimport means to make the classes and/or packages available in this program Beta.OutlineTracker;
08
09 /**
10 * All about my game here.
11 * @authorthis is the Javadoc tag for documenting who created the source code Jam Jenkins
12 */
13 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 TrackerExample2 extendsextends means to customize or extend the functionality of a class GameLoop
14 {open braces start code blocks and must be matched with a close brace
15
16 /**where the user clicks*/
17 privateprivate is used to restrict access to the current class only Point2D.Double whereClick;
18
19 privateprivate is used to restrict access to the current class only Sprite moving;
20
21 privateprivate is used to restrict access to the current class only OutlineTracker tracker;
22
23 /**makes a dot appear on the screen where the
24 user last clicked*/
25 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value makeDotAppear()
26 {open braces start code blocks and must be matched with a close brace
27 Sprite sprite=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor OvalSprite(1, 1);
28 sprite.setScale(0.1);
29 sprite.setLocation(whereClick);
30 canvas.addSprite(sprite);
31 }close braces end code blocks and must match an earlier open brace
32
33 /**calls makeDotAppear when the alarm goes off*/
34 classclass is a group of fields and methods used for making objects DotAppear implementsimplements means providing method bodies for the methods declared in the corresponding interface Alarm
35 {open braces start code blocks and must be matched with a close brace
36 /**simply calls makeDotAppear*/
37 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value alarm()
38 {open braces start code blocks and must be matched with a close brace
39 makeDotAppear();
40 }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
42
43 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value startGame()
44 {open braces start code blocks and must be matched with a close brace
45 moving=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor PolygonSprite(7);
46 moving.setScale(0.2);
47 moving.setLocation(0.5, 0.5);
48 canvas.addSprite(moving);
49
50 Sprite square=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor PolygonSprite(3);
51 square.setLocation(0.5, 0.5);
52
53 Sprite smallCircle=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor PolygonSprite(3);
54 smallCircle.setScale(0.1);
55 OutlineTracker small=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor OutlineTracker(smallCircle, 0.6);
56 small.setLooping(truetrue is the boolean value that is the opposite of false);
57
58 Point2D.Double direction=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor Point2D.Double(0, 0);
59 ProjectileTracker pTracker=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor ProjectileTracker(direction);
60 pTracker.setAngularVelocity(1);
61 tracker=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor OutlineTracker(square, 0.2);
62 tracker.setLooping(truetrue is the boolean value that is the opposite of false);
63 CompositeTracker composite=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor CompositeTracker();
64 composite.addTracker(tracker);
65 composite.addTracker(small);
66 composite.addTracker(pTracker);
67 moving.setLocation(tracker.getCurrentPoint());
68 moving.setTracker(composite);
69
70 setHelpText(
71 "Watch the moving shapes<br><br>"+adds two numbers together or concatenates Strings together
72 "More instructions here");
73 }close braces end code blocks and must match an earlier open brace
74
75 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)
76 {open braces start code blocks and must be matched with a close brace
77 Point2D.Double click=this assignment operator makes the left side equal to the right sidegetPlayer().getMouse().getClickLocation();
78 ifif executes the next statement only if the condition in parenthesis evaluates to true(click!=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)
79 {open braces start code blocks and must be matched with a close brace
80 scheduleRelative(newnew is used to create objects by calling the constructor DotAppear(), 1);
81 whereClick=this assignment operator makes the left side equal to the right sideclick;
82 }close braces end code blocks and must match an earlier open brace
83 }close braces end code blocks and must match an earlier open brace
84
85 }close braces end code blocks and must match an earlier open brace
|
Download/View Jam/TrackerExample2.java