|
001 packagepackage is used to name the directory or folder a class is in Jayson.art;
002 //package art;
003
004 importimport means to make the classes and/or packages available in this program wiki.Wiki;
005 importimport means to make the classes and/or packages available in this program fang.*;
006 importimport means to make the classes and/or packages available in this program java.awt.*;
007 importimport means to make the classes and/or packages available in this program java.awt.geom.*;
008 importimport means to make the classes and/or packages available in this program java.util.ArrayList;
009 importimport means to make the classes and/or packages available in this program Beta.OutlineTracker;
010
011 /**
012 * Super random. So random it hurts.
013 * @authorthis is the Javadoc tag for documenting who created the source code Jpark
014 */
015 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 Art extendsextends means to customize or extend the functionality of a class GameLoop
016 {open braces start code blocks and must be matched with a close brace
017 /**Polygons forfor is a looping structure for repeatedly executing a block of code the Pointer Trail.*/
018 privateprivate is used to restrict access to the current class only PolygonSprite[brackets are typically used to declare, initialize and index (indicate which element of) arrays]brackets are typically used to declare, initialize and index (indicate which element of) arrays snakePolyArray =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor PolygonSprite[brackets are typically used to declare, initialize and index (indicate which element of) arrays20]brackets are typically used to declare, initialize and index (indicate which element of) arrays;
019 /**Random shape created every couple of frames.*/
020 privateprivate is used to restrict access to the current class only Sprite randomShape;
021 /**The polygon shapes forfor is a looping structure for repeatedly executing a block of code the sparkTracks to track.*/
022 privateprivate is used to restrict access to the current class only Sprite[brackets are typically used to declare, initialize and index (indicate which element of) arrays]brackets are typically used to declare, initialize and index (indicate which element of) arrays trackShapes =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor Sprite[brackets are typically used to declare, initialize and index (indicate which element of) arrays3]brackets are typically used to declare, initialize and index (indicate which element of) arrays;
023 /**The sound that plays when the player presses r.*/
024 privateprivate is used to restrict access to the current class only Sound explode =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor Sound(Wiki.getMedia("Explosion3.wav"));
025 /**The sound that plays when the player clicks.*/
026 privateprivate is used to restrict access to the current class only Sound sparkSound =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor Sound(Wiki.getMedia("Laser1.wav"));
027 /**The images that goes around the trackShapes*/
028 privateprivate is used to restrict access to the current class only ImageSprite[brackets are typically used to declare, initialize and index (indicate which element of) arrays]brackets are typically used to declare, initialize and index (indicate which element of) arrays sparkTracks =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor ImageSprite[brackets are typically used to declare, initialize and index (indicate which element of) arrays3]brackets are typically used to declare, initialize and index (indicate which element of) arrays;
029 /**The Animated sprite created by the Author.*/
030 privateprivate is used to restrict access to the current class only ImageSprite spark =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor ImageSprite(Wiki.getMedia("Spark.gif"));
031 /**Click Location*/
032 privateprivate is used to restrict access to the current class only Point2D.Double clickLoc;
033 /**Track that outlines the track shapes.*/
034 privateprivate is used to restrict access to the current class only OutlineTracker[brackets are typically used to declare, initialize and index (indicate which element of) arrays]brackets are typically used to declare, initialize and index (indicate which element of) arrays tracks =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor OutlineTracker[brackets are typically used to declare, initialize and index (indicate which element of) arrays4]brackets are typically used to declare, initialize and index (indicate which element of) arrays;
035 /**Counts frames so the randomShape is not created so quickly.*/
036 privateprivate is used to restrict access to the current class only intint is the type for whole numbers and it is short for integer frameCounter =this assignment operator makes the left side equal to the right side 0;
037 /**Boolean variable so the randomized rotation of the
038 * Pointer Trail does not give a nullnull is the value used to refer to a non-existant object exception*/
039 privateprivate is used to restrict access to the current class only booleanboolean is a type that is either true or false firstSnake =this assignment operator makes the left side equal to the right side falsefalse is a value for the boolean type and means not true;
040 /**StringSprites forfor is a looping structure for repeatedly executing a block of code the author name.*/
041 privateprivate is used to restrict access to the current class only StringSprite author =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor StringSprite("Author: Jayson Park");
042 /**StringSprites forfor is a looping structure for repeatedly executing a block of code the title name.*/
043 privateprivate is used to restrict access to the current class only StringSprite title =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor StringSprite("Title: RandoKladio");
044 /***/
045 privateprivate is used to restrict access to the current class only OutlineTracker circleTrack;
046 privateprivate is used to restrict access to the current class only Sprite circle =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor OvalSprite(1,1);
047
048
049 /**sets up the game*/
050 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value startGame()
051 {open braces start code blocks and must be matched with a close brace
052 initArrays();
053 makeSprites();
054 addSprites();
055 setHelpText("<h1>RandoKladio</h1>" +adds two numbers together or concatenates Strings together
056 "Press r to Clear Screen." +adds two numbers together or concatenates Strings together
057 "Click to make a spark.");
058 }close braces end code blocks and must match an earlier open brace
059
060 /**Initializes all of the Arrays*/
061 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value initArrays()
062 {open braces start code blocks and must be matched with a close brace
063 forfor is a looping structure for repeatedly executing a block of code(intint is the type for whole numbers and it is short for integer makePoly =this assignment operator makes the left side equal to the right side 0; makePoly < 20; makePoly++this is the increment operator, which increases the variable by 1)
064 {open braces start code blocks and must be matched with a close brace
065 snakePolyArray[brackets are typically used to declare, initialize and index (indicate which element of) arraysmakePoly]brackets are typically used to declare, initialize and index (indicate which element of) arrays =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor PolygonSprite(6);
066 }close braces end code blocks and must match an earlier open brace
067 trackShapes[brackets are typically used to declare, initialize and index (indicate which element of) arrays0]brackets are typically used to declare, initialize and index (indicate which element of) arrays =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor PolygonSprite(7);
068 trackShapes[brackets are typically used to declare, initialize and index (indicate which element of) arrays1]brackets are typically used to declare, initialize and index (indicate which element of) arrays =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor PolygonSprite(5);
069 trackShapes[brackets are typically used to declare, initialize and index (indicate which element of) arrays2]brackets are typically used to declare, initialize and index (indicate which element of) arrays =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor PolygonSprite(3);
070 forfor is a looping structure for repeatedly executing a block of code(intint is the type for whole numbers and it is short for integer makeSparks =this assignment operator makes the left side equal to the right side 0; makeSparks < 3; makeSparks++this is the increment operator, which increases the variable by 1)
071 {open braces start code blocks and must be matched with a close brace
072 sparkTracks[brackets are typically used to declare, initialize and index (indicate which element of) arraysmakeSparks]brackets are typically used to declare, initialize and index (indicate which element of) arrays =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor ImageSprite(Wiki.getMedia("Spark.gif"));
073 }close braces end code blocks and must match an earlier open brace
074 }close braces end code blocks and must match an earlier open brace
075
076 /**makes the sprites*/
077 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value makeSprites()
078 {open braces start code blocks and must be matched with a close brace
079 circle.setScale(0.1);
080 author.setLocation(.2, .9);
081 title.setLocation(.2, .1);
082 author.setScale(.3);
083 title.setScale(.4);
084 forfor is a looping structure for repeatedly executing a block of code (intint is the type for whole numbers and it is short for integer sparkScale =this assignment operator makes the left side equal to the right side 0; sparkScale < 3; sparkScale++this is the increment operator, which increases the variable by 1)
085 {open braces start code blocks and must be matched with a close brace
086 sparkTracks[brackets are typically used to declare, initialize and index (indicate which element of) arrayssparkScale]brackets are typically used to declare, initialize and index (indicate which element of) arrays.setScale(0.1);
087 }close braces end code blocks and must match an earlier open brace
088 makeOutlineShapes();
089 createTracks();
090 makeTracks();
091 addTracks();
092 forfor is a looping structure for repeatedly executing a block of code (intint is the type for whole numbers and it is short for integer hideCounter =this assignment operator makes the left side equal to the right side 0; hideCounter < 20; hideCounter++this is the increment operator, which increases the variable by 1)
093 {open braces start code blocks and must be matched with a close brace
094 hideExtras(snakePolyArray[brackets are typically used to declare, initialize and index (indicate which element of) arrayshideCounter]brackets are typically used to declare, initialize and index (indicate which element of) arrays);
095 }close braces end code blocks and must match an earlier open brace
096 }close braces end code blocks and must match an earlier open brace
097
098 /**Hides the pointer trail shapes at the beginning.*/
099 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value hideExtras(Sprite sprite1)
100 {open braces start code blocks and must be matched with a close brace
101 sprite1.setScale(0);
102 sprite1.setLocation(0,0);
103 sprite1.setColor(Color.black);
104 }close braces end code blocks and must match an earlier open brace
105
106 /**Creates the shapes that deals with the Tracks*/
107 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value makeOutlineShapes()
108 {open braces start code blocks and must be matched with a close brace
109 trackShapes[brackets are typically used to declare, initialize and index (indicate which element of) arrays0]brackets are typically used to declare, initialize and index (indicate which element of) arrays =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor PolygonSprite(7);
110 trackShapes[brackets are typically used to declare, initialize and index (indicate which element of) arrays0]brackets are typically used to declare, initialize and index (indicate which element of) arrays.setLocation(.5, .5);
111 trackShapes[brackets are typically used to declare, initialize and index (indicate which element of) arrays0]brackets are typically used to declare, initialize and index (indicate which element of) arrays.setScale(.75);
112 trackShapes[brackets are typically used to declare, initialize and index (indicate which element of) arrays1]brackets are typically used to declare, initialize and index (indicate which element of) arrays =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor PolygonSprite(5);
113 trackShapes[brackets are typically used to declare, initialize and index (indicate which element of) arrays1]brackets are typically used to declare, initialize and index (indicate which element of) arrays.setLocation(.5, .5);
114 trackShapes[brackets are typically used to declare, initialize and index (indicate which element of) arrays1]brackets are typically used to declare, initialize and index (indicate which element of) arrays.setScale(.55);
115 trackShapes[brackets are typically used to declare, initialize and index (indicate which element of) arrays2]brackets are typically used to declare, initialize and index (indicate which element of) arrays =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor PolygonSprite(3);
116 trackShapes[brackets are typically used to declare, initialize and index (indicate which element of) arrays2]brackets are typically used to declare, initialize and index (indicate which element of) arrays.setLocation(.5, .5);
117 trackShapes[brackets are typically used to declare, initialize and index (indicate which element of) arrays2]brackets are typically used to declare, initialize and index (indicate which element of) arrays.setScale(.35);
118 }close braces end code blocks and must match an earlier open brace
119
120 /**Creates the Tracks forfor is a looping structure for repeatedly executing a block of code the shapes to go around.*/
121 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value createTracks()
122 {open braces start code blocks and must be matched with a close brace
123 tracks[brackets are typically used to declare, initialize and index (indicate which element of) arrays0]brackets are typically used to declare, initialize and index (indicate which element of) arrays =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor OutlineTracker(trackShapes[brackets are typically used to declare, initialize and index (indicate which element of) arrays0]brackets are typically used to declare, initialize and index (indicate which element of) arrays, 0.2);
124 tracks[brackets are typically used to declare, initialize and index (indicate which element of) arrays0]brackets are typically used to declare, initialize and index (indicate which element of) arrays.setLooping(truetrue is the boolean value that is the opposite of false);
125 tracks[brackets are typically used to declare, initialize and index (indicate which element of) arrays1]brackets are typically used to declare, initialize and index (indicate which element of) arrays =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor OutlineTracker(trackShapes[brackets are typically used to declare, initialize and index (indicate which element of) arrays1]brackets are typically used to declare, initialize and index (indicate which element of) arrays, -0.35);
126 tracks[brackets are typically used to declare, initialize and index (indicate which element of) arrays1]brackets are typically used to declare, initialize and index (indicate which element of) arrays.setLooping(truetrue is the boolean value that is the opposite of false);
127 tracks[brackets are typically used to declare, initialize and index (indicate which element of) arrays2]brackets are typically used to declare, initialize and index (indicate which element of) arrays =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor OutlineTracker(trackShapes[brackets are typically used to declare, initialize and index (indicate which element of) arrays2]brackets are typically used to declare, initialize and index (indicate which element of) arrays, .45);
128 tracks[brackets are typically used to declare, initialize and index (indicate which element of) arrays2]brackets are typically used to declare, initialize and index (indicate which element of) arrays.setLooping(truetrue is the boolean value that is the opposite of false);
129 circleTrack =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor OutlineTracker(circle, 1);
130 circleTrack.setLooping(truetrue is the boolean value that is the opposite of false);
131 }close braces end code blocks and must match an earlier open brace
132
133 /**Sets shapes to the track.*/
134 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value makeTracks()
135 {open braces start code blocks and must be matched with a close brace
136 forfor is a looping structure for repeatedly executing a block of code (intint is the type for whole numbers and it is short for integer settingTracks =this assignment operator makes the left side equal to the right side 0; settingTracks < 3; settingTracks++this is the increment operator, which increases the variable by 1)
137 {open braces start code blocks and must be matched with a close brace
138 sparkTracks[brackets are typically used to declare, initialize and index (indicate which element of) arrayssettingTracks]brackets are typically used to declare, initialize and index (indicate which element of) arrays.setLocation(tracks[brackets are typically used to declare, initialize and index (indicate which element of) arrayssettingTracks]brackets are typically used to declare, initialize and index (indicate which element of) arrays.getCurrentPoint());
139 sparkTracks[brackets are typically used to declare, initialize and index (indicate which element of) arrayssettingTracks]brackets are typically used to declare, initialize and index (indicate which element of) arrays.setTracker(tracks[brackets are typically used to declare, initialize and index (indicate which element of) arrayssettingTracks]brackets are typically used to declare, initialize and index (indicate which element of) arrays);
140 }close braces end code blocks and must match an earlier open brace
141 }close braces end code blocks and must match an earlier open brace
142
143 /**Synthesis of two trackers*/
144 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value addTracks()
145 {open braces start code blocks and must be matched with a close brace
146 CompositeTracker composite =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor CompositeTracker();
147 composite.addTracker(circleTrack);
148 composite.addTracker(tracks[brackets are typically used to declare, initialize and index (indicate which element of) arrays0]brackets are typically used to declare, initialize and index (indicate which element of) arrays);
149 sparkTracks[brackets are typically used to declare, initialize and index (indicate which element of) arrays0]brackets are typically used to declare, initialize and index (indicate which element of) arrays.setLocation(tracks[brackets are typically used to declare, initialize and index (indicate which element of) arrays0]brackets are typically used to declare, initialize and index (indicate which element of) arrays.getCurrentPoint());
150 sparkTracks[brackets are typically used to declare, initialize and index (indicate which element of) arrays0]brackets are typically used to declare, initialize and index (indicate which element of) arrays.setTracker(composite);
151 }close braces end code blocks and must match an earlier open brace
152
153 /**adds the sprites to the screen*/
154 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value addSprites()
155 {open braces start code blocks and must be matched with a close brace
156 forfor is a looping structure for repeatedly executing a block of code (intint is the type for whole numbers and it is short for integer addTrack =this assignment operator makes the left side equal to the right side 0; addTrack < 3; addTrack++this is the increment operator, which increases the variable by 1)
157 {open braces start code blocks and must be matched with a close brace
158 canvas.addSprite(trackShapes[brackets are typically used to declare, initialize and index (indicate which element of) arraysaddTrack]brackets are typically used to declare, initialize and index (indicate which element of) arrays);
159 }close braces end code blocks and must match an earlier open brace
160 forfor is a looping structure for repeatedly executing a block of code (intint is the type for whole numbers and it is short for integer addSparkTrack =this assignment operator makes the left side equal to the right side 0; addSparkTrack < 3; addSparkTrack++this is the increment operator, which increases the variable by 1)
161 {open braces start code blocks and must be matched with a close brace
162 canvas.addSprite(sparkTracks[brackets are typically used to declare, initialize and index (indicate which element of) arraysaddSparkTrack]brackets are typically used to declare, initialize and index (indicate which element of) arrays);
163 }close braces end code blocks and must match an earlier open brace
164 forfor is a looping structure for repeatedly executing a block of code (intint is the type for whole numbers and it is short for integer addTrail =this assignment operator makes the left side equal to the right side 0; addTrail < 20; addTrail++this is the increment operator, which increases the variable by 1)
165 {open braces start code blocks and must be matched with a close brace
166 canvas.addSprite(snakePolyArray[brackets are typically used to declare, initialize and index (indicate which element of) arraysaddTrail]brackets are typically used to declare, initialize and index (indicate which element of) arrays);
167 }close braces end code blocks and must match an earlier open brace
168 canvas.addSprite(author);
169 canvas.addSprite(title);
170 }close braces end code blocks and must match an earlier open brace
171
172 /**Creation of the spark.gif after the player clicks
173 * Creates 0.5 seconds after click.*/
174 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value createSpark()
175 {open braces start code blocks and must be matched with a close brace
176 spark =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor ImageSprite(Wiki.getMedia("Spark.gif"));
177 spark.setScale(0.02);
178 spark.setLocation(clickLoc);
179 scheduleRelative(newnew is used to create objects by calling the constructor ClickDelay(spark), 0.5);
180 }close braces end code blocks and must match an earlier open brace
181
182 /**Sets Color/Location of the first sprite of the pointer trail
183 * to the second. Also reduces the size.*/
184 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value incrementedTrail(Sprite sprite1, Sprite sprite2)
185 {open braces start code blocks and must be matched with a close brace
186 ifif executes the next statement only if the condition in parenthesis evaluates to true(sprite1 !=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)
187 {open braces start code blocks and must be matched with a close brace
188 sprite1.setColor(sprite2.getColor());
189 sprite1.setLocation(sprite2.getLocation());
190 sprite1.setScale(sprite2.getScale()-.005);
191 }close braces end code blocks and must match an earlier open brace
192 }close braces end code blocks and must match an earlier open brace
193
194 /**Creating the pointer trail.*/
195 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value colorSnake()
196 {open braces start code blocks and must be matched with a close brace
197 forfor is a looping structure for repeatedly executing a block of code (intint is the type for whole numbers and it is short for integer trailCount =this assignment operator makes the left side equal to the right side 19; trailCount > 0; trailCount--this is the decrement operator, which decreases the variable by 1)
198 {open braces start code blocks and must be matched with a close brace
199 incrementedTrail(snakePolyArray[brackets are typically used to declare, initialize and index (indicate which element of) arraystrailCount]brackets are typically used to declare, initialize and index (indicate which element of) arrays, snakePolyArray[brackets are typically used to declare, initialize and index (indicate which element of) arraystrailCount - 1]brackets are typically used to declare, initialize and index (indicate which element of) arrays);
200 }close braces end code blocks and must match an earlier open brace
201 snakePolyArray[brackets are typically used to declare, initialize and index (indicate which element of) arrays0]brackets are typically used to declare, initialize and index (indicate which element of) arrays.setColor(newnew is used to create objects by calling the constructor Color(random.nextInt()));
202 snakePolyArray[brackets are typically used to declare, initialize and index (indicate which element of) arrays0]brackets are typically used to declare, initialize and index (indicate which element of) arrays.setLocation(getPlayer().getMouse().getLocation());
203 snakePolyArray[brackets are typically used to declare, initialize and index (indicate which element of) arrays0]brackets are typically used to declare, initialize and index (indicate which element of) arrays.setScale(0.1);
204 }close braces end code blocks and must match an earlier open brace
205
206 /**Everything regarding the pointer trail except the creation.*/
207 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value snakeCoding()
208 {open braces start code blocks and must be matched with a close brace
209 ifif executes the next statement only if the condition in parenthesis evaluates to true (firstSnake ==this is the comparison operator which evaluates to true if both sides are the same falsefalse is a value for the boolean type and means not true)
210 {open braces start code blocks and must be matched with a close brace
211 firstSnake =this assignment operator makes the left side equal to the right side truetrue is the boolean value that is the opposite of false;
212 colorSnake();
213 }close braces end code blocks and must match an earlier open brace
214 snakePolyArray[brackets are typically used to declare, initialize and index (indicate which element of) arrays0]brackets are typically used to declare, initialize and index (indicate which element of) arrays.rotate(Math.random());
215 colorSnake();
216 }close braces end code blocks and must match an earlier open brace
217
218 /**Randomizes the color of the Sprite that is sent.*/
219 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value colorRandomizer(Sprite spriteColorChange)
220 {open braces start code blocks and must be matched with a close brace
221 spriteColorChange.setColor(newnew is used to create objects by calling the constructor Color(random.nextInt()));
222 }close braces end code blocks and must match an earlier open brace
223
224 /**Removes all of the Sprites so the computer doesn't crash
225 * Recreates the Sprites.*/
226 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value reset()
227 {open braces start code blocks and must be matched with a close brace
228 explode.setSoundPosition(0);
229 explode.play();
230 canvas.removeAllSprites();
231 addSprites();
232 }close braces end code blocks and must match an earlier open brace
233
234 /**Creates a random Shape every 15 frames.*/
235 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value randomShapes()
236 {open braces start code blocks and must be matched with a close brace
237 ifif executes the next statement only if the condition in parenthesis evaluates to true(frameCounter ==this is the comparison operator which evaluates to true if both sides are the same 15)
238 {open braces start code blocks and must be matched with a close brace
239 frameCounter =this assignment operator makes the left side equal to the right side 0;
240 ifif executes the next statement only if the condition in parenthesis evaluates to true (randomShape !=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)
241 {open braces start code blocks and must be matched with a close brace
242 canvas.removeSprite(randomShape);
243 }close braces end code blocks and must match an earlier open brace
244 randomShape =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor PolygonSprite((intint is the type for whole numbers and it is short for integer)Math.ceil(Math.random()*12+adds two numbers together or concatenates Strings together3));
245 randomShape.setScale(Math.random()*0.25+adds two numbers together or concatenates Strings together.05);
246 randomShape.setLocation(Math.random()*0.9, Math.random()*0.9);
247 colorRandomizer(randomShape);
248 canvas.addSprite(randomShape);
249 }close braces end code blocks and must match an earlier open brace
250 frameCounter++this is the increment operator, which increases the variable by 1;
251 }close braces end code blocks and must match an earlier open brace
252
253 /**Methods dealing with tracks in the advanced frame.
254 * Changes color and rotation.*/
255 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value trackFrames()
256 {open braces start code blocks and must be matched with a close brace
257 forfor is a looping structure for repeatedly executing a block of code (intint is the type for whole numbers and it is short for integer colorCount =this assignment operator makes the left side equal to the right side 0; colorCount < 3; colorCount++this is the increment operator, which increases the variable by 1)
258 {open braces start code blocks and must be matched with a close brace
259 colorRandomizer(trackShapes[brackets are typically used to declare, initialize and index (indicate which element of) arrayscolorCount]brackets are typically used to declare, initialize and index (indicate which element of) arrays);
260 }close braces end code blocks and must match an earlier open brace
261 trackShapes[brackets are typically used to declare, initialize and index (indicate which element of) arrays0]brackets are typically used to declare, initialize and index (indicate which element of) arrays.rotate(.02);
262 trackShapes[brackets are typically used to declare, initialize and index (indicate which element of) arrays1]brackets are typically used to declare, initialize and index (indicate which element of) arrays.rotate( -.1);
263 trackShapes[brackets are typically used to declare, initialize and index (indicate which element of) arrays2]brackets are typically used to declare, initialize and index (indicate which element of) arrays.rotate(.2);
264 }close braces end code blocks and must match an earlier open brace
265
266 /**Changes color randomly forfor is a looping structure for repeatedly executing a block of code the 2 StringSprites*/
267 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value textFrames()
268 {open braces start code blocks and must be matched with a close brace
269 colorRandomizer(author);
270 colorRandomizer(title);
271 }close braces end code blocks and must match an earlier open brace
272
273 /**Deals with anything in the advanceFrame forfor is a looping structure for repeatedly executing a block of code player interaction.*/
274 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value interactionFrame()
275 {open braces start code blocks and must be matched with a close brace
276 ifif executes the next statement only if the condition in parenthesis evaluates to true (getPlayer().getKeyboard().getLastKey() ==this is the comparison operator which evaluates to true if both sides are the same 'r')
277 {open braces start code blocks and must be matched with a close brace
278 reset();
279 }close braces end code blocks and must match an earlier open brace
280 Point2D.Double clickLoc2 =this assignment operator makes the left side equal to the right side getPlayer().getMouse().getClickLocation();
281 ifif executes the next statement only if the condition in parenthesis evaluates to true (clickLoc2 !=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)
282 {open braces start code blocks and must be matched with a close brace
283 clickLoc =this assignment operator makes the left side equal to the right side clickLoc2;
284 sparkSound.setSoundPosition(1);
285 sparkSound.play();
286 createSpark();
287 }close braces end code blocks and must match an earlier open brace
288 }close braces end code blocks and must match an earlier open brace
289
290 /**handle input and game events*/
291 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)
292 {open braces start code blocks and must be matched with a close brace
293 trackFrames();
294 textFrames();
295 interactionFrame();
296 randomShapes();
297 snakeCoding();
298 }close braces end code blocks and must match an earlier open brace
299
300 /**Class to create and Image a specified time after a click.*/
301 privateprivate is used to restrict access to the current class only classclass is a group of fields and methods used for making objects ClickDelay implementsimplements means providing method bodies for the methods declared in the corresponding interface Alarm
302 {open braces start code blocks and must be matched with a close brace
303 privateprivate is used to restrict access to the current class only Sprite spark;
304 publicpublic is used to indicate unrestricted access (any other class can have access) ClickDelay(Sprite sprite)
305 {open braces start code blocks and must be matched with a close brace
306 spark =this assignment operator makes the left side equal to the right side sprite;
307 }close braces end code blocks and must match an earlier open brace
308
309 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value alarm()
310 {open braces start code blocks and must be matched with a close brace
311 canvas.addSprite(spark);
312 }close braces end code blocks and must match an earlier open brace
313 }close braces end code blocks and must match an earlier open brace
314 }close braces end code blocks and must match an earlier open brace
|