|
001 //package wackadot;
002 packagepackage is used to name the directory or folder a class is in Jayson.finalassign;
003 importimport means to make the classes and/or packages available in this program wiki.Wiki;
004 importimport means to make the classes and/or packages available in this program fang.*;
005 importimport means to make the classes and/or packages available in this program java.awt.*;
006 importimport means to make the classes and/or packages available in this program java.awt.geom.*;
007 /**
008 * Wackadot Enhancements Final Assignment
009 * @authorthis is the Javadoc tag for documenting who created the source code Jayson Park
010 */
011 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 WackadotEnhance extendsextends means to customize or extend the functionality of a class GameLoop
012 {open braces start code blocks and must be matched with a close brace
013 /**Sides forfor is a looping structure for repeatedly executing a block of code the sprites to bounce off of*/
014 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 bound =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) arrays4]brackets are typically used to declare, initialize and index (indicate which element of) arrays;
015 /**Array forfor is a looping structure for repeatedly executing a block of code the dots*/
016 privateprivate is used to restrict access to the current class only PolygonSides[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 dots =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor PolygonSides[brackets are typically used to declare, initialize and index (indicate which element of) arrays7]brackets are typically used to declare, initialize and index (indicate which element of) arrays;
017 /**Array forfor is a looping structure for repeatedly executing a block of code the colors*/
018 privateprivate is used to restrict access to the current class only Color[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 colors =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor Color[brackets are typically used to declare, initialize and index (indicate which element of) arrays6]brackets are typically used to declare, initialize and index (indicate which element of) arrays;
019 /**Array forfor is a looping structure for repeatedly executing a block of code the star gifs in the background*/
020 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 stars =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) arrays10]brackets are typically used to declare, initialize and index (indicate which element of) arrays;
021 /**Array forfor is a looping structure for repeatedly executing a block of code the trackers forfor is a looping structure for repeatedly executing a block of code the dots*/
022 privateprivate is used to restrict access to the current class only ProjectileTracker[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 dotTracker =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor ProjectileTracker[brackets are typically used to declare, initialize and index (indicate which element of) arrays6]brackets are typically used to declare, initialize and index (indicate which element of) arrays;
023 /**String forfor is a looping structure for repeatedly executing a block of code the score and timer*/
024 privateprivate is used to restrict access to the current class only StringSprite scoreSprite, timerSprite;
025 /**Integers forfor is a looping structure for repeatedly executing a block of code the actual score and time that is left.*/
026 privateprivate is used to restrict access to the current class only intint is the type for whole numbers and it is short for integer score, timeLeft;
027 /**Double value forfor is a looping structure for repeatedly executing a block of code the normal value to bounce.*/
028 privateprivate is used to restrict access to the current class only doubledouble is the type for numbers that can contain decimal fractions normal;
029 /**Initializations forfor is a looping structure for repeatedly executing a block of code the sounds*/
030 Sound plus, minus;
031 /**Main method*/
032 publicpublic is used to indicate unrestricted access (any other class can have access) staticstatic means that an instance is not required for access (class level access) voidvoid means the method does not return a value mainThe main method is the place where applications begin executing.(String[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 args)
033 {open braces start code blocks and must be matched with a close brace
034 WackadotEnhance wack =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor WackadotEnhance();
035 wack.runAsApplication();
036 }close braces end code blocks and must match an earlier open brace
037 /**Pregame variable setting.*/
038 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value startGame()
039 {open braces start code blocks and must be matched with a close brace
040 score =this assignment operator makes the left side equal to the right side 0;
041 timeLeft =this assignment operator makes the left side equal to the right side 60;
042 makeSprites();
043 scheduleRelative(newnew is used to create objects by calling the constructor TimeUpdater(), 1);
044 plus =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("Arrow.wav"));
045 minus =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("Boom1.wav"));
046 }close braces end code blocks and must match an earlier open brace
047 /**Sets it so the ball bounces when it hits the paddle or boundary*/
048 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value dotBounce(Sprite surface, intint is the type for whole numbers and it is short for integer dotInt)
049 {open braces start code blocks and must be matched with a close brace
050 normal =this assignment operator makes the left side equal to the right side Sprite.getNormalVector(surface.getShape(), dots[brackets are typically used to declare, initialize and index (indicate which element of) arraysdotInt]brackets are typically used to declare, initialize and index (indicate which element of) arrays.getShape());
051 dotTracker[brackets are typically used to declare, initialize and index (indicate which element of) arraysdotInt]brackets are typically used to declare, initialize and index (indicate which element of) arrays.bounce(normal);
052 }close braces end code blocks and must match an earlier open brace
053 /**Make the trackers and sets to the dots.*/
054 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value makeTracks()
055 {open braces start code blocks and must be matched with a close brace
056 dotTracker[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 ProjectileTracker(.25, .25);
057 dotTracker[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 ProjectileTracker(-.25, .25);
058 dotTracker[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 ProjectileTracker(0, -.25);
059 dotTracker[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 =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor ProjectileTracker(-.25, -.25);
060 dotTracker[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 =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor ProjectileTracker(.25, 0);
061 dotTracker[brackets are typically used to declare, initialize and index (indicate which element of) arrays5]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 ProjectileTracker(0, .25);
062 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 i =this assignment operator makes the left side equal to the right side 0; i < dotTracker.length; i++this is the increment operator, which increases the variable by 1)
063 {open braces start code blocks and must be matched with a close brace
064 dots[brackets are typically used to declare, initialize and index (indicate which element of) arraysi+adds two numbers together or concatenates Strings together1]brackets are typically used to declare, initialize and index (indicate which element of) arrays.setTracker(dotTracker[brackets are typically used to declare, initialize and index (indicate which element of) arraysi]brackets are typically used to declare, initialize and index (indicate which element of) arrays);
065 }close braces end code blocks and must match an earlier open brace
066 }close braces end code blocks and must match an earlier open brace
067 /**Updates timer every second*/
068 classclass is a group of fields and methods used for making objects TimeUpdater implementsimplements means providing method bodies for the methods declared in the corresponding interface Alarm
069 {open braces start code blocks and must be matched with a close brace
070 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value alarm()
071 {open braces start code blocks and must be matched with a close brace
072 timeLeft--this is the decrement operator, which decreases the variable by 1;
073 updateTimer();
074 ifif executes the next statement only if the condition in parenthesis evaluates to true (timeLeft > 0)
075 {open braces start code blocks and must be matched with a close brace
076 scheduleRelative(thisthis means the current object (the implicit parameter), 1);
077 }close braces end code blocks and must match an earlier open brace
078 }close braces end code blocks and must match an earlier open brace
079 }close braces end code blocks and must match an earlier open brace
080 /**Creation of Sprites, sets the colors, shapes, etc.*/
081 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value makeSprites()
082 {open braces start code blocks and must be matched with a close brace
083 makeStars();
084 makeBound();
085 makeColors();
086 makeMouseDot();
087 doubledouble is the type for numbers that can contain decimal fractions scaleDot =this assignment operator makes the left side equal to the right side 0;
088 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 i =this assignment operator makes the left side equal to the right side 1; i < dots.length; i++this is the increment operator, which increases the variable by 1)
089 {open braces start code blocks and must be matched with a close brace
090 scaleDot =this assignment operator makes the left side equal to the right side scaleNormalDot(i);
091 otherDots(colors[brackets are typically used to declare, initialize and index (indicate which element of) arraysi - 1]brackets are typically used to declare, initialize and index (indicate which element of) arrays, i, scaleDot);
092 }close braces end code blocks and must match an earlier open brace
093 makeTracks();
094 makeScoreTimer();
095 }close braces end code blocks and must match an earlier open brace
096 /**Creates the boundaries around the level.*/
097 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value makeBound()
098 {open braces start code blocks and must be matched with a close brace
099 bound[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 RectangleSprite(.1,2);
100 bound[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 RectangleSprite(.1,2);
101 bound[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 RectangleSprite(2,.1);
102 bound[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 =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor RectangleSprite(2,.1);
103 bound[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(1.1,.5);
104 bound[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(-.1,.5);
105 bound[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,-.1);
106 bound[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.setLocation(.5,1.1);
107 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 i =this assignment operator makes the left side equal to the right side 0; i < bound.length; i++this is the increment operator, which increases the variable by 1)
108 {open braces start code blocks and must be matched with a close brace
109 bound[brackets are typically used to declare, initialize and index (indicate which element of) arraysi]brackets are typically used to declare, initialize and index (indicate which element of) arrays.setScale(.5);
110 canvas.addSprite(bound[brackets are typically used to declare, initialize and index (indicate which element of) arraysi]brackets are typically used to declare, initialize and index (indicate which element of) arrays);
111 }close braces end code blocks and must match an earlier open brace
112 }close braces end code blocks and must match an earlier open brace
113 /**Returns value forfor is a looping structure for repeatedly executing a block of code scale depending on array element sent in.*/
114 privateprivate is used to restrict access to the current class only doubledouble is the type for numbers that can contain decimal fractions scaleNormalDot(intint is the type for whole numbers and it is short for integer i)
115 {open braces start code blocks and must be matched with a close brace
116 ifif executes the next statement only if the condition in parenthesis evaluates to true (i %this divides the left side by the right side and evaluates to the remainder 2 ==this is the comparison operator which evaluates to true if both sides are the same 0)
117 returnreturn means to provide the result of the method and/or cease execution of the method immediately (.15);
118 elseelse is what happens when the if condition is false
119 returnreturn means to provide the result of the method and/or cease execution of the method immediately (.1);
120 }close braces end code blocks and must match an earlier open brace
121 /**Makes the stars in the background.*/
122 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value makeStars()
123 {open braces start code blocks and must be matched with a close brace
124 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 i =this assignment operator makes the left side equal to the right side 0; i < stars.length; i++this is the increment operator, which increases the variable by 1)
125 {open braces start code blocks and must be matched with a close brace
126 stars[brackets are typically used to declare, initialize and index (indicate which element of) arraysi]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("Star1.gif"));
127 stars[brackets are typically used to declare, initialize and index (indicate which element of) arraysi]brackets are typically used to declare, initialize and index (indicate which element of) arrays.setLocation(random.nextDouble(), random.nextDouble());
128 stars[brackets are typically used to declare, initialize and index (indicate which element of) arraysi]brackets are typically used to declare, initialize and index (indicate which element of) arrays.setScale(.10);
129 canvas.addSprite(stars[brackets are typically used to declare, initialize and index (indicate which element of) arraysi]brackets are typically used to declare, initialize and index (indicate which element of) arrays);
130 }close braces end code blocks and must match an earlier open brace
131 }close braces end code blocks and must match an earlier open brace
132 /**Creates the score and the timer text.*/
133 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value makeScoreTimer()
134 {open braces start code blocks and must be matched with a close brace
135 scoreSprite =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor StringSprite("Score: " +adds two numbers together or concatenates Strings together score);
136 scoreSprite.setHeight(0.1);
137 scoreSprite.rightJustify();
138 scoreSprite.topJustify();
139 scoreSprite.setLocation(1, 0);
140 canvas.addSprite(scoreSprite);
141 timerSprite =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor StringSprite("Timer: " +adds two numbers together or concatenates Strings together timeLeft);
142 timerSprite.leftJustify();
143 timerSprite.topJustify();
144 timerSprite.setHeight(0.1);
145 timerSprite.setLocation(0, 0);
146 canvas.addSprite(timerSprite);
147 }close braces end code blocks and must match an earlier open brace
148 /**Creates the dot that the mouse controls.*/
149 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value makeMouseDot()
150 {open braces start code blocks and must be matched with a close brace
151 dots[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 PolygonSides(random.nextInt(7)+adds two numbers together or concatenates Strings together3);
152 dots[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);
153 dots[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(0.5, 0.5);
154 dots[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(colors[brackets are typically used to declare, initialize and index (indicate which element of) arraysrandom.nextInt(5)]brackets are typically used to declare, initialize and index (indicate which element of) arrays);
155 canvas.addSprite(dots[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);
156 }close braces end code blocks and must match an earlier open brace
157 /**Creates the other dots that is not the one controlled by the player.*/
158 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value otherDots(Color dotColor, intint is the type for whole numbers and it is short for integer dotNum,
159 doubledouble is the type for numbers that can contain decimal fractions scale)
160 {open braces start code blocks and must be matched with a close brace
161 dots[brackets are typically used to declare, initialize and index (indicate which element of) arraysdotNum]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 PolygonSides(random.nextInt(7)+adds two numbers together or concatenates Strings together3);
162 dots[brackets are typically used to declare, initialize and index (indicate which element of) arraysdotNum]brackets are typically used to declare, initialize and index (indicate which element of) arrays.setScale(scale);
163 dots[brackets are typically used to declare, initialize and index (indicate which element of) arraysdotNum]brackets are typically used to declare, initialize and index (indicate which element of) arrays.setLocation(random.nextDouble(), random.nextDouble());
164 dots[brackets are typically used to declare, initialize and index (indicate which element of) arraysdotNum]brackets are typically used to declare, initialize and index (indicate which element of) arrays.setColor(dotColor);
165 canvas.addSprite(dots[brackets are typically used to declare, initialize and index (indicate which element of) arraysdotNum]brackets are typically used to declare, initialize and index (indicate which element of) arrays);
166 }close braces end code blocks and must match an earlier open brace
167 /**Sets colors to the color array.*/
168 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value makeColors()
169 {open braces start code blocks and must be matched with a close brace
170 colors[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 Color.RED;
171 colors[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 Color.BLUE;
172 colors[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 Color.GREEN;
173 colors[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 =this assignment operator makes the left side equal to the right side Color.PINK;
174 colors[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 =this assignment operator makes the left side equal to the right side Color.WHITE;
175 colors[brackets are typically used to declare, initialize and index (indicate which element of) arrays5]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 Color.YELLOW;
176 }close braces end code blocks and must match an earlier open brace
177 /**Updates the score*/
178 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value updateScore()
179 {open braces start code blocks and must be matched with a close brace
180 scoreSprite.setText("Score: " +adds two numbers together or concatenates Strings together score);
181 }close braces end code blocks and must match an earlier open brace
182 /**Changes the location of the sprite to a random one.*/
183 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value repositionRandomly(Sprite sprite)
184 {open braces start code blocks and must be matched with a close brace
185 sprite.setLocation(random.nextDouble(), random.nextDouble());
186 }close braces end code blocks and must match an earlier open brace
187 /**Changes the scale of the dots, ifif executes the next statement only if the condition in parenthesis evaluates to true goes to 0, repositions, then reverts scale size.*/
188 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value changeScaleDots()
189 {open braces start code blocks and must be matched with a close brace
190 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 i =this assignment operator makes the left side equal to the right side 1; i < dots.length; i++this is the increment operator, which increases the variable by 1)
191 {open braces start code blocks and must be matched with a close brace
192 dots[brackets are typically used to declare, initialize and index (indicate which element of) arraysi]brackets are typically used to declare, initialize and index (indicate which element of) arrays.setScale(dots[brackets are typically used to declare, initialize and index (indicate which element of) arraysi]brackets are typically used to declare, initialize and index (indicate which element of) arrays.getScale() - .0025);
193 ifif executes the next statement only if the condition in parenthesis evaluates to true (dots[brackets are typically used to declare, initialize and index (indicate which element of) arraysi]brackets are typically used to declare, initialize and index (indicate which element of) arrays.getScale() <=this evaluates to true if the left side is not more than the right side 0.005)
194 {open braces start code blocks and must be matched with a close brace
195 repositionRandomly(dots[brackets are typically used to declare, initialize and index (indicate which element of) arraysi]brackets are typically used to declare, initialize and index (indicate which element of) arrays);
196 dots[brackets are typically used to declare, initialize and index (indicate which element of) arraysi]brackets are typically used to declare, initialize and index (indicate which element of) arrays.setScale(scaleNormalDot(i));
197 }close braces end code blocks and must match an earlier open brace
198 }close braces end code blocks and must match an earlier open brace
199 }close braces end code blocks and must match an earlier open brace
200 /**Check forfor is a looping structure for repeatedly executing a block of code a Reset*/
201 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value checkReset()
202 {open braces start code blocks and must be matched with a close brace
203 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')
204 {open braces start code blocks and must be matched with a close brace
205 score =this assignment operator makes the left side equal to the right side 0;
206 timeLeft =this assignment operator makes the left side equal to the right side 60;
207 updateTimer();
208 updateScore();
209 }close braces end code blocks and must match an earlier open brace
210 }close braces end code blocks and must match an earlier open brace
211 /**Frame advances 30 FPS*/
212 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)
213 {open braces start code blocks and must be matched with a close brace
214 ifif executes the next statement only if the condition in parenthesis evaluates to true (timeLeft > 0)
215 {open braces start code blocks and must be matched with a close brace
216 Point2D.Double mouse =this assignment operator makes the left side equal to the right side getPlayer().getMouse().getLocation();
217 dots[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(mouse);
218 handleCollisions();
219 }close braces end code blocks and must match an earlier open brace
220 checkReset();
221 changeScaleDots();
222 rotateDots();
223 }close braces end code blocks and must match an earlier open brace
224 /**Rotates the dots every frame.*/
225 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value rotateDots()
226 {open braces start code blocks and must be matched with a close brace
227 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 i =this assignment operator makes the left side equal to the right side 0; i < dots.length; i++this is the increment operator, which increases the variable by 1)
228 {open braces start code blocks and must be matched with a close brace
229 dots[brackets are typically used to declare, initialize and index (indicate which element of) arraysi]brackets are typically used to declare, initialize and index (indicate which element of) arrays.rotate(.01);
230 }close braces end code blocks and must match an earlier open brace
231 }close braces end code blocks and must match an earlier open brace
232 /**Method to update the timer in the display.*/
233 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value updateTimer()
234 {open braces start code blocks and must be matched with a close brace
235 timerSprite.setText("Timer: " +adds two numbers together or concatenates Strings together timeLeft);
236 }close braces end code blocks and must match an earlier open brace
237 /**Method to check ifif executes the next statement only if the condition in parenthesis evaluates to true the dot correctly intersected the right shape/color*/
238 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value checkIntersect(intint is the type for whole numbers and it is short for integer i)
239 {open braces start code blocks and must be matched with a close brace
240 ifif executes the next statement only if the condition in parenthesis evaluates to true (dots[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.getColor().equals(dots[brackets are typically used to declare, initialize and index (indicate which element of) arraysi]brackets are typically used to declare, initialize and index (indicate which element of) arrays.getColor()) &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 &&) dots[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.getSides()!=this is the not equals operator which evaluates to true if both sides are differentdots[brackets are typically used to declare, initialize and index (indicate which element of) arraysi]brackets are typically used to declare, initialize and index (indicate which element of) arrays.getSides())
241 {open braces start code blocks and must be matched with a close brace
242 dots[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(colors[brackets are typically used to declare, initialize and index (indicate which element of) arraysrandom.nextInt(6)]brackets are typically used to declare, initialize and index (indicate which element of) arrays);
243 score++this is the increment operator, which increases the variable by 1;
244 plus.play();
245 }close braces end code blocks and must match an earlier open brace
246 elseelse is what happens when the if condition is false
247 ifif executes the next statement only if the condition in parenthesis evaluates to true (!this is the not operator, which changes true to false and false to truedots[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.getColor().equals(dots[brackets are typically used to declare, initialize and index (indicate which element of) arraysi]brackets are typically used to declare, initialize and index (indicate which element of) arrays.getColor()) &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 &&) dots[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.getSides()==this is the comparison operator which evaluates to true if both sides are the samedots[brackets are typically used to declare, initialize and index (indicate which element of) arraysi]brackets are typically used to declare, initialize and index (indicate which element of) arrays.getSides())
248 {open braces start code blocks and must be matched with a close brace
249 dots[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(colors[brackets are typically used to declare, initialize and index (indicate which element of) arraysrandom.nextInt(6)]brackets are typically used to declare, initialize and index (indicate which element of) arrays);
250 score++this is the increment operator, which increases the variable by 1;
251 plus.play();
252 }close braces end code blocks and must match an earlier open brace
253 elseelse is what happens when the if condition is false
254 {open braces start code blocks and must be matched with a close brace
255 score--this is the decrement operator, which decreases the variable by 1;
256 minus.play();
257 }close braces end code blocks and must match an earlier open brace
258 }close braces end code blocks and must match an earlier open brace
259 /**Method that holds all of the collisions with the mouse and the Sprites on screen.*/
260 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value handleCollisions()
261 {open braces start code blocks and must be matched with a close brace
262 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 i =this assignment operator makes the left side equal to the right side 2; i < dots.length; i++this is the increment operator, which increases the variable by 1)
263 {open braces start code blocks and must be matched with a close brace
264 ifif executes the next statement only if the condition in parenthesis evaluates to true(dots[brackets are typically used to declare, initialize and index (indicate which element of) arraysi-1]brackets are typically used to declare, initialize and index (indicate which element of) arrays.intersects(dots[brackets are typically used to declare, initialize and index (indicate which element of) arraysi]brackets are typically used to declare, initialize and index (indicate which element of) arrays))
265 {open braces start code blocks and must be matched with a close brace
266 dotBounce(dots[brackets are typically used to declare, initialize and index (indicate which element of) arraysi]brackets are typically used to declare, initialize and index (indicate which element of) arrays, i-1);
267 }close braces end code blocks and must match an earlier open brace
268 }close braces end code blocks and must match an earlier open brace
269 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 i =this assignment operator makes the left side equal to the right side 1; i < dots.length; i++this is the increment operator, which increases the variable by 1)
270 {open braces start code blocks and must be matched with a close brace
271 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 j =this assignment operator makes the left side equal to the right side 0; j < bound.length; j++this is the increment operator, which increases the variable by 1)
272 {open braces start code blocks and must be matched with a close brace
273 ifif executes the next statement only if the condition in parenthesis evaluates to true (dots[brackets are typically used to declare, initialize and index (indicate which element of) arraysi]brackets are typically used to declare, initialize and index (indicate which element of) arrays.intersects(bound[brackets are typically used to declare, initialize and index (indicate which element of) arraysj]brackets are typically used to declare, initialize and index (indicate which element of) arrays))
274 {open braces start code blocks and must be matched with a close brace
275 dotBounce(bound[brackets are typically used to declare, initialize and index (indicate which element of) arraysj]brackets are typically used to declare, initialize and index (indicate which element of) arrays, i-1);
276 }close braces end code blocks and must match an earlier open brace
277 }close braces end code blocks and must match an earlier open brace
278 }close braces end code blocks and must match an earlier open brace
279 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 i =this assignment operator makes the left side equal to the right side 1; i < dots.length; i++this is the increment operator, which increases the variable by 1)
280 {open braces start code blocks and must be matched with a close brace
281 ifif executes the next statement only if the condition in parenthesis evaluates to true (dots[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.intersects(dots[brackets are typically used to declare, initialize and index (indicate which element of) arraysi]brackets are typically used to declare, initialize and index (indicate which element of) arrays))
282 {open braces start code blocks and must be matched with a close brace
283 repositionRandomly(dots[brackets are typically used to declare, initialize and index (indicate which element of) arraysi]brackets are typically used to declare, initialize and index (indicate which element of) arrays);
284 canvas.removeSprite(dots[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);
285 makeMouseDot();
286 checkIntersect(i);
287 updateScore();
288 }close braces end code blocks and must match an earlier open brace
289 }close braces end code blocks and must match an earlier open brace
290 }close braces end code blocks and must match an earlier open brace
291 }close braces end code blocks and must match an earlier open brace
292 /**Class that adds the method getSides forfor is a looping structure for repeatedly executing a block of code the PolygonSprite*/
293 classclass is a group of fields and methods used for making objects PolygonSides extendsextends means to customize or extend the functionality of a class PolygonSprite
294 {open braces start code blocks and must be matched with a close brace
295 intint is the type for whole numbers and it is short for integer sides =this assignment operator makes the left side equal to the right side 0;
296 PolygonSides(intint is the type for whole numbers and it is short for integer sidesGiven)
297 {open braces start code blocks and must be matched with a close brace
298 super(sidesGiven);
299 sides =this assignment operator makes the left side equal to the right side sidesGiven;
300 }close braces end code blocks and must match an earlier open brace
301 publicpublic is used to indicate unrestricted access (any other class can have access) intint is the type for whole numbers and it is short for integer getSides()
302 {open braces start code blocks and must be matched with a close brace
303 returnreturn means to provide the result of the method and/or cease execution of the method immediately(sides);
304 }close braces end code blocks and must match an earlier open brace
305 }close braces end code blocks and must match an earlier open brace
|