|
001 packagepackage is used to name the directory or folder a class is in NickandChris;
002
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 /**
009 * All about my game here.
010 * @authorthis is the Javadoc tag for documenting who created the source code Nmckee
011 */
012 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 BreakoutFinal extendsextends means to customize or extend the functionality of a class GameLoop
013 {open braces start code blocks and must be matched with a close brace
014 privateprivate is used to restrict access to the current class only Sprite blocks[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;
015 privateprivate is used to restrict access to the current class only StringSprite displayScore, displayLives, win, clear, lose;
016 privateprivate is used to restrict access to the current class only intint is the type for whole numbers and it is short for integer lives, score;
017 privateprivate is used to restrict access to the current class only Sprite leftWall;
018 privateprivate is used to restrict access to the current class only Sprite rightWall;
019 privateprivate is used to restrict access to the current class only Sprite topWall;
020 privateprivate is used to restrict access to the current class only Sprite bottomWall;
021 privateprivate is used to restrict access to the current class only Sprite paddle;
022 privateprivate is used to restrict access to the current class only Sound sound1, sound2, sound3, sound4, sound5, sound6;
023 privateprivate is used to restrict access to the current class only Sprite ball, ball2, ball3;
024 privateprivate is used to restrict access to the current class only ProjectileTracker tracker, tracker2, tracker3;
025 privateprivate is used to restrict access to the current class only intint is the type for whole numbers and it is short for integer stage;
026
027 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value startGame()
028 {open braces start code blocks and must be matched with a close brace
029 stage=this assignment operator makes the left side equal to the right side0;
030 stages();
031 togglePause();
032 toggleAudible();
033 toggleSound();
034 makeSounds();
035 }close braces end code blocks and must match an earlier open brace
036
037
038 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value stages()
039 {open braces start code blocks and must be matched with a close brace
040 ifif executes the next statement only if the condition in parenthesis evaluates to true(stage==this is the comparison operator which evaluates to true if both sides are the same0)
041 {open braces start code blocks and must be matched with a close brace
042 lives=this assignment operator makes the left side equal to the right side4;
043 score=this assignment operator makes the left side equal to the right side49;
044 blocks=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor Sprite[brackets are typically used to declare, initialize and index (indicate which element of) arrays50]brackets are typically used to declare, initialize and index (indicate which element of) arrays;
045 makeBlocks();
046 makeSprites();
047 makeTracker();
048 makeBounces();
049 canvas.addSprite(ball);
050 }close braces end code blocks and must match an earlier open brace
051
052 }close braces end code blocks and must match an earlier open brace
053
054 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value toggleSound()
055 {open braces start code blocks and must be matched with a close brace
056 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 'm')
057 {open braces start code blocks and must be matched with a close brace
058 toggleAudible();
059 }close braces end code blocks and must match an earlier open brace
060 }close braces end code blocks and must match an earlier open brace
061
062 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value stageClear()
063 {open braces start code blocks and must be matched with a close brace
064 Point2D.Double click=this assignment operator makes the left side equal to the right sidegetPlayer().getMouse().getClickLocation();
065 ifif executes the next statement only if the condition in parenthesis evaluates to true(stage==this is the comparison operator which evaluates to true if both sides are the same0 &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 &&) score==this is the comparison operator which evaluates to true if both sides are the same50 &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 &&) 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)
066 {open braces start code blocks and must be matched with a close brace
067 stageTwo();
068 }close braces end code blocks and must match an earlier open brace
069 ifif executes the next statement only if the condition in parenthesis evaluates to true(stage==this is the comparison operator which evaluates to true if both sides are the same1 &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 &&) score==this is the comparison operator which evaluates to true if both sides are the same50 &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 &&) 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)
070 {open braces start code blocks and must be matched with a close brace
071 stageThree();
072 }close braces end code blocks and must match an earlier open brace
073 }close braces end code blocks and must match an earlier open brace
074
075 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value makeSprites()
076 {open braces start code blocks and must be matched with a close brace
077 makeScore();
078 makeLives();
079 makePaddleandBall();
080 makeWalls();
081 makeOutcome();
082 }close braces end code blocks and must match an earlier open brace
083
084 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value stageTwo()
085 {open braces start code blocks and must be matched with a close brace
086 stage=this assignment operator makes the left side equal to the right side1;
087 lives=this assignment operator makes the left side equal to the right side4;
088 score=this assignment operator makes the left side equal to the right side0;
089 canvas.removeAllSprites();
090 makeWalls();
091 //canvas.removeSprite(displayLives, displayScore, clear);
092 canvas.addSprite(ball, ball2, paddle);
093 ball.setLocation(.5, .7);
094 ball2.setLocation(.5, .7);
095 leftWall.setColor(Color.RED);
096 rightWall.setColor(Color.RED);
097 topWall.setColor(Color.RED);
098 paddle.setScale(.19);
099 makeBlocks();
100 makeOutcome();
101 makeScore();
102 makeLives();
103 }close braces end code blocks and must match an earlier open brace
104
105 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value stageThree()
106 {open braces start code blocks and must be matched with a close brace
107 stage=this assignment operator makes the left side equal to the right side2;
108 lives=this assignment operator makes the left side equal to the right side6;
109 score=this assignment operator makes the left side equal to the right side0;
110 canvas.removeAllSprites();
111 //canvas.removeSprite(displayLives, displayScore, clear);
112 canvas.addSprite(ball, ball2, ball3, paddle);
113 ball.setLocation(.5, .7);
114 ball2.setLocation(.5, .7);
115 ball3.setLocation(.5, .7);
116 paddle.setScale(.15);
117 makeBlocks();
118 makeOutcome();
119 makeScore();
120 makeLives();
121 }close braces end code blocks and must match an earlier open brace
122
123 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value makeBlocks()
124 {open braces start code blocks and must be matched with a close brace
125 intint is the type for whole numbers and it is short for integer index=this assignment operator makes the left side equal to the right side0;
126 intint is the type for whole numbers and it is short for integer numBlocksHigh=this assignment operator makes the left side equal to the right side5;
127 doubledouble is the type for numbers that can contain decimal fractions startLocationY=this assignment operator makes the left side equal to the right side0.1;
128 doubledouble is the type for numbers that can contain decimal fractions endLocationY=this assignment operator makes the left side equal to the right side0.3;
129 doubledouble is the type for numbers that can contain decimal fractions distanceHigh=this assignment operator makes the left side equal to the right sideendLocationY-startLocationY;
130 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 side0; j<numBlocksHigh; j++this is the increment operator, which increases the variable by 1)
131 {open braces start code blocks and must be matched with a close brace
132 doubledouble is the type for numbers that can contain decimal fractions y=this assignment operator makes the left side equal to the right sidej*distanceHigh/(numBlocksHigh-1)+adds two numbers together or concatenates Strings togetherstartLocationY;
133
134 intint is the type for whole numbers and it is short for integer numBlocksAcross=this assignment operator makes the left side equal to the right side10;
135 doubledouble is the type for numbers that can contain decimal fractions startLocationX=this assignment operator makes the left side equal to the right side0.1;
136 doubledouble is the type for numbers that can contain decimal fractions endLocationX=this assignment operator makes the left side equal to the right side1-startLocationX;
137 doubledouble is the type for numbers that can contain decimal fractions distanceAcross=this assignment operator makes the left side equal to the right sideendLocationX-startLocationX;
138 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 side0; i<numBlocksAcross; i++this is the increment operator, which increases the variable by 1)
139 {open braces start code blocks and must be matched with a close brace
140 doubledouble is the type for numbers that can contain decimal fractions x=this assignment operator makes the left side equal to the right sidei*distanceAcross/(numBlocksAcross-1)+adds two numbers together or concatenates Strings togetherstartLocationX;
141 blocks[brackets are typically used to declare, initialize and index (indicate which element of) arraysindex]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 sidenewnew is used to create objects by calling the constructor RectangleSprite(2.4, 1.25);
142 blocks[brackets are typically used to declare, initialize and index (indicate which element of) arraysindex]brackets are typically used to declare, initialize and index (indicate which element of) arrays.setScale(.075);
143 blocks[brackets are typically used to declare, initialize and index (indicate which element of) arraysindex]brackets are typically used to declare, initialize and index (indicate which element of) arrays.setLocation(x, y);
144 blocks[brackets are typically used to declare, initialize and index (indicate which element of) arraysindex]brackets are typically used to declare, initialize and index (indicate which element of) arrays.setColor(Color.BLUE);
145 ifif executes the next statement only if the condition in parenthesis evaluates to true(stage==this is the comparison operator which evaluates to true if both sides are the same1)
146 {open braces start code blocks and must be matched with a close brace
147 blocks[brackets are typically used to declare, initialize and index (indicate which element of) arraysindex]brackets are typically used to declare, initialize and index (indicate which element of) arrays.setColor(Color.WHITE);
148 }close braces end code blocks and must match an earlier open brace
149 ifif executes the next statement only if the condition in parenthesis evaluates to true(stage==this is the comparison operator which evaluates to true if both sides are the same2)
150 {open braces start code blocks and must be matched with a close brace
151 blocks[brackets are typically used to declare, initialize and index (indicate which element of) arraysindex]brackets are typically used to declare, initialize and index (indicate which element of) arrays.setColor(Color.GREEN);
152 }close braces end code blocks and must match an earlier open brace
153 canvas.addSprite(blocks[brackets are typically used to declare, initialize and index (indicate which element of) arraysindex]brackets are typically used to declare, initialize and index (indicate which element of) arrays);
154 index++this is the increment operator, which increases the variable by 1;
155 }close braces end code blocks and must match an earlier open brace
156 }close braces end code blocks and must match an earlier open brace
157 }close braces end code blocks and must match an earlier open brace
158
159 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value makeScore()
160 {open braces start code blocks and must be matched with a close brace
161 displayScore =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 togetherscore);
162 displayScore.setLocation(0.3, .95);
163 displayScore.setColor(Color.WHITE);
164 displayScore.setScale(0.175);
165 canvas.addSprite(displayScore);
166 }close braces end code blocks and must match an earlier open brace
167
168
169 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value makeLives()
170 {open braces start code blocks and must be matched with a close brace
171 displayLives =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor StringSprite("Lives: "+adds two numbers together or concatenates Strings togetherlives);
172 displayLives.setLocation(0.7, .95);
173 displayLives.setColor(Color.WHITE);
174 displayLives.setScale(0.175);
175 canvas.addSprite(displayLives);
176 }close braces end code blocks and must match an earlier open brace
177
178 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value resetGame()
179 {open braces start code blocks and must be matched with a close brace
180 ifif executes the next statement only if the condition in parenthesis evaluates to true(lives==this is the comparison operator which evaluates to true if both sides are the same0 &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 &&) getPlayer().getKeyboard().getLastKey() ==this is the comparison operator which evaluates to true if both sides are the same 'r')
181 {open braces start code blocks and must be matched with a close brace
182 canvas.removeAllSprites();
183 stage=this assignment operator makes the left side equal to the right side0;
184 startGame();
185 }close braces end code blocks and must match an earlier open brace
186 }close braces end code blocks and must match an earlier open brace
187
188 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value togglePause()
189 {open braces start code blocks and must be matched with a close brace
190 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 'p')
191 {open braces start code blocks and must be matched with a close brace
192 pauseToggle();
193 }close braces end code blocks and must match an earlier open brace
194 }close braces end code blocks and must match an earlier open brace
195
196 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value makePaddleandBall()
197 {open braces start code blocks and must be matched with a close brace
198 paddle=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor RectangleSprite(25, 1);
199 paddle.setColor(Color.YELLOW);
200 paddle.setScale(.15);
201 paddle.setLocation(.5, .8);
202 canvas.addSprite(paddle);
203
204 ball=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor OvalSprite(1, 1);
205 ball.setColor(Color.RED);
206 ball.setScale(0.03);
207 ball.setLocation(.5, .7);
208
209 ball2=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor OvalSprite(1, 1);
210 ball2.setColor(Color.BLUE);
211 ball2.setScale(0.03);
212 ball2.setLocation(.5, .7);
213
214 ball3=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor OvalSprite(1, 1);
215 ball3.setColor(Color.GREEN);
216 ball3.setScale(0.03);
217 ball3.setLocation(.5, .7);
218 }close braces end code blocks and must match an earlier open brace
219
220 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value makeWalls()
221 {open braces start code blocks and must be matched with a close brace
222 leftWall=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor RectangleSprite(3, 50);
223 leftWall.setLocation(0.015, 0.5);
224 leftWall.setScale(1);
225 leftWall.setColor(Color.YELLOW);
226 canvas.addSprite(leftWall);
227
228 rightWall=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor RectangleSprite(3, 50);
229 rightWall.setLocation(.985, 0.5);
230 rightWall.setScale(1);
231 rightWall.setColor(Color.YELLOW);
232 canvas.addSprite(rightWall);
233
234 topWall=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor RectangleSprite(50, 3);
235 topWall.setLocation(0.5, 0);
236 topWall.setScale(1);
237 topWall.setColor(Color.YELLOW);
238 canvas.addSprite(topWall);
239
240 bottomWall=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor RectangleSprite(50, 1);
241 bottomWall.setLocation(0.5, 0.99);
242 bottomWall.setScale(1);
243 bottomWall.setColor(Color.BLACK);
244 canvas.addSprite(bottomWall);
245 }close braces end code blocks and must match an earlier open brace
246
247 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value makeTracker()
248 {open braces start code blocks and must be matched with a close brace
249 tracker=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor ProjectileTracker(.1,-0.5);
250 tracker2=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor ProjectileTracker(.1,-0.5);
251 tracker3=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor ProjectileTracker(.1, -0.5);
252 ball.setTracker(tracker);
253 ball2.setTracker(tracker2);
254 ball3.setTracker(tracker3);
255
256 }close braces end code blocks and must match an earlier open brace
257
258 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value makeSounds()
259 {open braces start code blocks and must be matched with a close brace
260 sound1 =this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor Sound(Wiki.getMedia("Applause22.wav"));
261 sound2 =this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor Sound(Wiki.getMedia("Boingfinal.wav"));
262 sound3 =this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor Sound(Wiki.getMedia("Doh22.wav"));
263 sound4 =this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor Sound(Wiki.getMedia("Hithard.wav"));
264 sound5 =this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor Sound(Wiki.getMedia("Byebyefinal.wav"));
265 sound6 =this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor Sound(Wiki.getMedia("Drums.wav"));
266 }close braces end code blocks and must match an earlier open brace
267
268
269 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)
270 {open braces start code blocks and must be matched with a close brace
271 doubledouble is the type for numbers that can contain decimal fractions x=this assignment operator makes the left side equal to the right sidegetPlayer().getMouse().getLocation().x;
272 paddle.setLocation(x,paddle.getLocation().y);
273 makeBounces();
274 hitsBlocks();
275 stageClear();
276 togglePause();
277 toggleSound();
278 resetGame();
279 }close braces end code blocks and must match an earlier open brace
280
281
282 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value makeOutcome()
283 {open braces start code blocks and must be matched with a close brace
284 ifif executes the next statement only if the condition in parenthesis evaluates to true(lives==this is the comparison operator which evaluates to true if both sides are the same0)
285 {open braces start code blocks and must be matched with a close brace
286 lose=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor StringSprite("You Lose! Press R to reset the game.");
287 lose.setLocation(0.5, 0.5);
288 lose.setScale(.8);
289 lose.setColor(Color.WHITE);
290 canvas.addSprite(lose);
291 canvas.removeSprite(ball, ball2, ball3, paddle);
292 sound3.play();
293 }close braces end code blocks and must match an earlier open brace
294
295 ifif executes the next statement only if the condition in parenthesis evaluates to true(score==this is the comparison operator which evaluates to true if both sides are the same50 &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 &&) stage==this is the comparison operator which evaluates to true if both sides are the same2)
296 {open braces start code blocks and must be matched with a close brace
297 canvas.removeAllSprites();
298 win=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor StringSprite("You Win!");
299 win.setLocation(0.5, 0.5);
300 win.setScale(.4);
301 win.setColor(Color.WHITE);
302 canvas.addSprite(win);
303 sound1.play();
304 }close braces end code blocks and must match an earlier open brace
305 ifif executes the next statement only if the condition in parenthesis evaluates to true(score==this is the comparison operator which evaluates to true if both sides are the same50)
306 {open braces start code blocks and must be matched with a close brace
307 ifif executes the next statement only if the condition in parenthesis evaluates to true(stage==this is the comparison operator which evaluates to true if both sides are the same0 ||this is boolean or, meaning if either or both are true then the result is true stage==this is the comparison operator which evaluates to true if both sides are the same1)
308 {open braces start code blocks and must be matched with a close brace
309 clear=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor StringSprite("Stage Cleared! Click to Continue.");
310 clear.setLocation(0.5, 0.5);
311 clear.setScale(.8);
312 clear.setColor(Color.WHITE);
313 canvas.addSprite(clear);
314 sound6.play();
315 canvas.removeSprite(ball, ball2, ball3, paddle);
316
317 }close braces end code blocks and must match an earlier open brace
318
319 }close braces end code blocks and must match an earlier open brace
320 }close braces end code blocks and must match an earlier open brace
321
322
323
324
325 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value makeBounces()
326 {open braces start code blocks and must be matched with a close brace
327 ifif executes the next statement only if the condition in parenthesis evaluates to true(ball.intersects(ball2) ||this is boolean or, meaning if either or both are true then the result is true ball.intersects(ball3))
328 {open braces start code blocks and must be matched with a close brace
329 doubledouble is the type for numbers that can contain decimal fractions normal2=this assignment operator makes the left side equal to the right sideSprite.getNormalVector(ball2.getShape(), ball2.getShape());
330 doubledouble is the type for numbers that can contain decimal fractions normal3=this assignment operator makes the left side equal to the right sideSprite.getNormalVector(ball3.getShape(), ball3.getShape());
331 tracker2.bounce(normal2);
332 tracker3.bounce(normal3);
333
334 }close braces end code blocks and must match an earlier open brace
335 ifif executes the next statement only if the condition in parenthesis evaluates to true(ball2.intersects(ball) ||this is boolean or, meaning if either or both are true then the result is true ball2.intersects(ball3))
336 {open braces start code blocks and must be matched with a close brace
337 doubledouble is the type for numbers that can contain decimal fractions normal=this assignment operator makes the left side equal to the right sideSprite.getNormalVector(ball.getShape(), ball.getShape());
338 doubledouble is the type for numbers that can contain decimal fractions normal3=this assignment operator makes the left side equal to the right sideSprite.getNormalVector(ball3.getShape(), ball3.getShape());
339 tracker.bounce(normal);
340 tracker3.bounce(normal3);
341
342 }close braces end code blocks and must match an earlier open brace
343 ifif executes the next statement only if the condition in parenthesis evaluates to true(ball3.intersects(ball2) ||this is boolean or, meaning if either or both are true then the result is true ball3.intersects(ball))
344 {open braces start code blocks and must be matched with a close brace
345 doubledouble is the type for numbers that can contain decimal fractions normal=this assignment operator makes the left side equal to the right sideSprite.getNormalVector(ball.getShape(), ball.getShape());
346 doubledouble is the type for numbers that can contain decimal fractions normal2=this assignment operator makes the left side equal to the right sideSprite.getNormalVector(ball2.getShape(), ball2.getShape());
347 tracker.bounce(normal);
348 tracker2.bounce(normal2);
349
350 }close braces end code blocks and must match an earlier open brace
351
352
353 ifif executes the next statement only if the condition in parenthesis evaluates to true(paddle.intersects(ball) ||this is boolean or, meaning if either or both are true then the result is true paddle.intersects(ball2) ||this is boolean or, meaning if either or both are true then the result is true paddle.intersects(ball3))
354 {open braces start code blocks and must be matched with a close brace
355 doubledouble is the type for numbers that can contain decimal fractions normal=this assignment operator makes the left side equal to the right sideSprite.getNormalVector(paddle.getShape(), ball.getShape());
356 doubledouble is the type for numbers that can contain decimal fractions normal2=this assignment operator makes the left side equal to the right sideSprite.getNormalVector(paddle.getShape(), ball2.getShape());
357 doubledouble is the type for numbers that can contain decimal fractions normal3=this assignment operator makes the left side equal to the right sideSprite.getNormalVector(paddle.getShape(), ball3.getShape());
358 tracker.bounce(normal);
359 tracker2.bounce(normal2);
360 tracker3.bounce(normal3);
361 sound2.play();
362
363 }close braces end code blocks and must match an earlier open brace
364
365 ifif executes the next statement only if the condition in parenthesis evaluates to true(rightWall.intersects(ball) ||this is boolean or, meaning if either or both are true then the result is true rightWall.intersects(ball2) ||this is boolean or, meaning if either or both are true then the result is true rightWall.intersects(ball3))
366 {open braces start code blocks and must be matched with a close brace
367 doubledouble is the type for numbers that can contain decimal fractions normal=this assignment operator makes the left side equal to the right sideSprite.getNormalVector(rightWall.getShape(), ball.getShape());
368 doubledouble is the type for numbers that can contain decimal fractions normal2=this assignment operator makes the left side equal to the right sideSprite.getNormalVector(rightWall.getShape(), ball2.getShape());
369 doubledouble is the type for numbers that can contain decimal fractions normal3=this assignment operator makes the left side equal to the right sideSprite.getNormalVector(rightWall.getShape(), ball3.getShape());
370 tracker.bounce(normal);
371 tracker2.bounce(normal2);
372 tracker3.bounce(normal3);
373
374 }close braces end code blocks and must match an earlier open brace
375
376 ifif executes the next statement only if the condition in parenthesis evaluates to true(leftWall.intersects(ball) ||this is boolean or, meaning if either or both are true then the result is true leftWall.intersects(ball2) ||this is boolean or, meaning if either or both are true then the result is true leftWall.intersects(ball3))
377 {open braces start code blocks and must be matched with a close brace
378 doubledouble is the type for numbers that can contain decimal fractions normal=this assignment operator makes the left side equal to the right sideSprite.getNormalVector(leftWall.getShape(), ball.getShape());
379 doubledouble is the type for numbers that can contain decimal fractions normal2=this assignment operator makes the left side equal to the right sideSprite.getNormalVector(leftWall.getShape(), ball2.getShape());
380 doubledouble is the type for numbers that can contain decimal fractions normal3=this assignment operator makes the left side equal to the right sideSprite.getNormalVector(leftWall.getShape(), ball3.getShape());
381 tracker.bounce(normal);
382 tracker2.bounce(normal2);
383 tracker3.bounce(normal3);
384
385 }close braces end code blocks and must match an earlier open brace
386
387 ifif executes the next statement only if the condition in parenthesis evaluates to true(topWall.intersects(ball) ||this is boolean or, meaning if either or both are true then the result is true topWall.intersects(ball2) ||this is boolean or, meaning if either or both are true then the result is true topWall.intersects(ball3))
388 {open braces start code blocks and must be matched with a close brace
389 doubledouble is the type for numbers that can contain decimal fractions normal=this assignment operator makes the left side equal to the right sideSprite.getNormalVector(topWall.getShape(), ball.getShape());
390 doubledouble is the type for numbers that can contain decimal fractions normal2=this assignment operator makes the left side equal to the right sideSprite.getNormalVector(topWall.getShape(), ball2.getShape());
391 doubledouble is the type for numbers that can contain decimal fractions normal3=this assignment operator makes the left side equal to the right sideSprite.getNormalVector(topWall.getShape(), ball3.getShape());
392 tracker.bounce(normal);
393 tracker2.bounce(normal2);
394 tracker3.bounce(normal3);
395
396 }close braces end code blocks and must match an earlier open brace
397
398
399
400 }close braces end code blocks and must match an earlier open brace
401
402 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value hitsBlocks()
403 {open braces start code blocks and must be matched with a close brace
404 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 side0; i<blocks.length; i++this is the increment operator, which increases the variable by 1)
405 {open braces start code blocks and must be matched with a close brace
406 ifif executes the next statement only if the condition in parenthesis evaluates to true(blocks[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.isVisible() &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 &&) blocks[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(ball) ||this is boolean or, meaning if either or both are true then the result is true blocks[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.isVisible() &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 &&) blocks[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(ball2) ||this is boolean or, meaning if either or both are true then the result is true blocks[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.isVisible() &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 &&) blocks[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(ball3))
407 {open braces start code blocks and must be matched with a close brace
408 doubledouble is the type for numbers that can contain decimal fractions normal=this assignment operator makes the left side equal to the right sideSprite.getNormalVector(blocks[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.getShape(), ball.getShape());
409 doubledouble is the type for numbers that can contain decimal fractions normal2=this assignment operator makes the left side equal to the right sideSprite.getNormalVector(blocks[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.getShape(), ball2.getShape());
410 doubledouble is the type for numbers that can contain decimal fractions normal3=this assignment operator makes the left side equal to the right sideSprite.getNormalVector(blocks[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.getShape(), ball3.getShape());
411 score++this is the increment operator, which increases the variable by 1;
412 displayScore.setText("Score: "+adds two numbers together or concatenates Strings togetherscore);
413 tracker.bounce(normal);
414 tracker2.bounce(normal2);
415 tracker3.bounce(normal3);
416 blocks[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.setVisible(falsefalse is a value for the boolean type and means not true);
417 makeOutcome();
418 sound4.play();
419
420 }close braces end code blocks and must match an earlier open brace
421 }close braces end code blocks and must match an earlier open brace
422
423 ifif executes the next statement only if the condition in parenthesis evaluates to true(bottomWall.intersects(ball) ||this is boolean or, meaning if either or both are true then the result is true bottomWall.intersects(ball2) ||this is boolean or, meaning if either or both are true then the result is true bottomWall.intersects(ball3))
424 {open braces start code blocks and must be matched with a close brace
425 lives--this is the decrement operator, which decreases the variable by 1;
426 displayLives.setText("Lives: "+adds two numbers together or concatenates Strings togetherlives);
427 ifif executes the next statement only if the condition in parenthesis evaluates to true(bottomWall.intersects(ball))
428 {open braces start code blocks and must be matched with a close brace
429 ball.setLocation(.5,.5);
430 }close braces end code blocks and must match an earlier open brace
431 ifif executes the next statement only if the condition in parenthesis evaluates to true(bottomWall.intersects(ball2))
432 {open braces start code blocks and must be matched with a close brace
433 ball2.setLocation(.5,.5);
434 }close braces end code blocks and must match an earlier open brace
435 ifif executes the next statement only if the condition in parenthesis evaluates to true(bottomWall.intersects(ball3))
436 {open braces start code blocks and must be matched with a close brace
437 ball3.setLocation(.5,.5);
438 }close braces end code blocks and must match an earlier open brace
439 makeOutcome();
440 sound5.play();
441 }close braces end code blocks and must match an earlier open brace
442
443 }close braces end code blocks and must match an earlier open brace
444 }close braces end code blocks and must match an earlier open brace
|