|
001 packagepackage is used to name the directory or folder a class is in Jayson.breakout;
002 //package breakout;
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
010 /**
011 * Classic Breakout with a twist.
012 * @authorthis is the Javadoc tag for documenting who created the source code Jayson Park
013 */
014 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 Breakout extendsextends means to customize or extend the functionality of a class GameLoop
015 {open braces start code blocks and must be matched with a close brace
016 /**Array of bricks forfor is a looping structure for repeatedly executing a block of code the game to create*/
017 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 bricks;
018 /**Array forfor is a looping structure for repeatedly executing a block of code the brick colors*/
019 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 brickColor;
020 /**Number of Bricks in the X and Y directions*/
021 privateprivate is used to restrict access to the current class only intint is the type for whole numbers and it is short for integer numBricksX, numBricksY;
022 /**Starting X and Y Coordinates*/
023 privateprivate is used to restrict access to the current class only doubledouble is the type for numbers that can contain decimal fractions startYCoord, startXCoord;
024 /**Size of the bricks.*/
025 privateprivate is used to restrict access to the current class only doubledouble is the type for numbers that can contain decimal fractions brickWidth, brickHeight;
026 /**Coordinates forfor is a looping structure for repeatedly executing a block of code the current brick*/
027 privateprivate is used to restrict access to the current class only doubledouble is the type for numbers that can contain decimal fractions yCoord, xCoord;
028 /**Sprites forfor is a looping structure for repeatedly executing a block of code the boundaries.*/
029 privateprivate is used to restrict access to the current class only Sprite leftWall, rightWall, topCeiling;
030 /**Array forfor is a looping structure for repeatedly executing a block of code the areas where the ball calls death()*/
031 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 deadArea =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;
032 /**Sprites forfor is a looping structure for repeatedly executing a block of code the paddle*/
033 privateprivate is used to restrict access to the current class only Sprite paddle;
034 /**Array forfor is a looping structure for repeatedly executing a block of code balls*/
035 privateprivate is used to restrict access to the current class only ArrayList<Sprite> ball =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor ArrayList<Sprite>();
036 /**Sprites forfor is a looping structure for repeatedly executing a block of code the score, reset text, and number of lives*/
037 privateprivate is used to restrict access to the current class only StringSprite scoreText, resetText, livesText;
038 /**Score and lives values*/
039 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, lives;
040 /**Chance forfor is a looping structure for repeatedly executing a block of code a power up to drop*/
041 privateprivate is used to restrict access to the current class only intint is the type for whole numbers and it is short for integer powerChance;
042 /**Game over status*/
043 privateprivate is used to restrict access to the current class only booleanboolean is a type that is either true or false gameOver =this assignment operator makes the left side equal to the right side falsefalse is a value for the boolean type and means not true;
044 /**Tracker forfor is a looping structure for repeatedly executing a block of code the ball*/
045 privateprivate is used to restrict access to the current class only ArrayList<ProjectileTracker> ballTracker =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor ArrayList<ProjectileTracker>();
046 /**Double value forfor is a looping structure for repeatedly executing a block of code the normal value to bounce.*/
047 privateprivate is used to restrict access to the current class only doubledouble is the type for numbers that can contain decimal fractions normal;
048 /**Amount of bricks left.*/
049 privateprivate is used to restrict access to the current class only intint is the type for whole numbers and it is short for integer brickAmount;
050 /**Frame to add all Sprites forfor is a looping structure for repeatedly executing a block of code rotating frame*/
051 privateprivate is used to restrict access to the current class only SpriteFrame frame =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor SpriteFrame();
052 /**Array containing all of the power ups*/
053 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 powerUps =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) arrays7]brackets are typically used to declare, initialize and index (indicate which element of) arrays;
054 /**Tracker forfor is a looping structure for repeatedly executing a block of code the power ups to fall*/
055 privateprivate is used to restrict access to the current class only ProjectileTracker powerUpTracker =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);
056 /**So the rotation would work forfor is a looping structure for repeatedly executing a block of code the directions*/
057 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 marker =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) arrays2]brackets are typically used to declare, initialize and index (indicate which element of) arrays;
058 /**Toggle forfor is a looping structure for repeatedly executing a block of code the breakOut power up*/
059 privateprivate is used to restrict access to the current class only booleanboolean is a type that is either true or false breakoutToggle =this assignment operator makes the left side equal to the right side falsefalse is a value for the boolean type and means not true;
060 /**Length of the ball to perserve the ball array length*/
061 privateprivate is used to restrict access to the current class only intint is the type for whole numbers and it is short for integer lengthBall =this assignment operator makes the left side equal to the right side 1;
062
063 /**sets up the game*/
064 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value startGame()
065 {open braces start code blocks and must be matched with a close brace
066 makeSprites();
067 setHelpText("<h1>Control the paddle</h1> Hit the bricks with the ball.");
068 }close braces end code blocks and must match an earlier open brace
069
070 /**Temporary mainThe main method is the place where applications begin executing. method forfor is a looping structure for repeatedly executing a block of code the IDE to work*/
071 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)
072 {open braces start code blocks and must be matched with a close brace
073 //Constructor
074 Breakout breakout =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor Breakout();
075 //Special method to fix some errors.
076 breakout.runAsApplication();
077 }close braces end code blocks and must match an earlier open brace
078
079 /**makes the sprites*/
080 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value makeSprites()
081 {open braces start code blocks and must be matched with a close brace
082 levelOneAssign();
083 makeBrickColors();
084 makeBricks();
085 makePowerUps();
086 makePaddle();
087 makeBall(0);
088 makeScoreText();
089 makeLivesText();
090 makeLevelBoundaries();
091 }close braces end code blocks and must match an earlier open brace
092
093 /**Sets the number/size of bricks
094 * and the Starting Coordinates forfor is a looping structure for repeatedly executing a block of code level One.*/
095 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value levelOneAssign()
096 {open braces start code blocks and must be matched with a close brace
097 lives =this assignment operator makes the left side equal to the right side 5;
098 score =this assignment operator makes the left side equal to the right side 0;
099 powerChance =this assignment operator makes the left side equal to the right side 5;
100 lengthBall =this assignment operator makes the left side equal to the right side 1;
101 numBricksX =this assignment operator makes the left side equal to the right side 16;
102 numBricksY =this assignment operator makes the left side equal to the right side 8;
103 startYCoord =this assignment operator makes the left side equal to the right side .4;
104 startXCoord =this assignment operator makes the left side equal to the right side .1;
105 brickWidth =this assignment operator makes the left side equal to the right side (1 - 2 * startXCoord) / (numBricksX - 1);
106 brickHeight =this assignment operator makes the left side equal to the right side brickWidth / 2.5;
107 }close braces end code blocks and must match an earlier open brace
108
109 /**Creates colors forfor is a looping structure for repeatedly executing a block of code the bricks*/
110 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value makeBrickColors()
111 {open braces start code blocks and must be matched with a close brace
112 brickColor =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) arraysnumBricksY]brackets are typically used to declare, initialize and index (indicate which element of) arrays;
113 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 colorInt =this assignment operator makes the left side equal to the right side 0; colorInt < numBricksY; colorInt++this is the increment operator, which increases the variable by 1)
114 {open braces start code blocks and must be matched with a close brace
115 brickColor[brackets are typically used to declare, initialize and index (indicate which element of) arrayscolorInt]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 colorOrder(colorInt);
116 }close braces end code blocks and must match an earlier open brace
117 }close braces end code blocks and must match an earlier open brace
118
119 /**Sets the order of which color is the strongest*/
120 publicpublic is used to indicate unrestricted access (any other class can have access) Color colorOrder(intint is the type for whole numbers and it is short for integer colorNum)
121 {open braces start code blocks and must be matched with a close brace
122 Color colorReturn;
123 switchswitch is used with case for multiple alternatives (like if/else if...) (colorNum)
124 {open braces start code blocks and must be matched with a close brace
125 casecase is used with switch for multiple alternatives (like if/else if...) 0:
126 colorReturn =this assignment operator makes the left side equal to the right side Color.blue;
127 breakbreak terminates the loop immediately;
128 casecase is used with switch for multiple alternatives (like if/else if...) 1:
129 colorReturn =this assignment operator makes the left side equal to the right side Color.red;
130 breakbreak terminates the loop immediately;
131 casecase is used with switch for multiple alternatives (like if/else if...) 2:
132 colorReturn =this assignment operator makes the left side equal to the right side Color.yellow;
133 breakbreak terminates the loop immediately;
134 casecase is used with switch for multiple alternatives (like if/else if...) 3:
135 colorReturn =this assignment operator makes the left side equal to the right side Color.cyan;
136 breakbreak terminates the loop immediately;
137 casecase is used with switch for multiple alternatives (like if/else if...) 4:
138 colorReturn =this assignment operator makes the left side equal to the right side Color.green;
139 breakbreak terminates the loop immediately;
140 casecase is used with switch for multiple alternatives (like if/else if...) 5:
141 colorReturn =this assignment operator makes the left side equal to the right side Color.white;
142 breakbreak terminates the loop immediately;
143 defaultdefault is what is executed when no cases are matched:
144 colorReturn =this assignment operator makes the left side equal to the right side Color.darkGray;
145 }close braces end code blocks and must match an earlier open brace
146 returnreturn means to provide the result of the method and/or cease execution of the method immediately (colorReturn);
147 }close braces end code blocks and must match an earlier open brace
148
149 /**Creates the bricks*/
150 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value makeBricks()
151 {open braces start code blocks and must be matched with a close brace
152 bricks =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) arraysnumBricksX * numBricksY]brackets are typically used to declare, initialize and index (indicate which element of) arrays;
153 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 < numBricksY; i++this is the increment operator, which increases the variable by 1)
154 {open braces start code blocks and must be matched with a close brace
155 yCoord =this assignment operator makes the left side equal to the right side startYCoord - (i * brickHeight);
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 a =this assignment operator makes the left side equal to the right side 0; a < numBricksX; a++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 xCoord =this assignment operator makes the left side equal to the right side startXCoord +adds two numbers together or concatenates Strings together a * brickWidth;
159 bricks[brackets are typically used to declare, initialize and index (indicate which element of) arrays(i * numBricksX) +adds two numbers together or concatenates Strings together
160 a]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(brickWidth, brickHeight);
161 bricks[brackets are typically used to declare, initialize and index (indicate which element of) arrays(i * numBricksX) +adds two numbers together or concatenates Strings together a]brackets are typically used to declare, initialize and index (indicate which element of) arrays.setColor(brickColor[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);
162 bricks[brackets are typically used to declare, initialize and index (indicate which element of) arrays(i * numBricksX) +adds two numbers together or concatenates Strings together a]brackets are typically used to declare, initialize and index (indicate which element of) arrays.setLocation(xCoord, yCoord);
163 bricks[brackets are typically used to declare, initialize and index (indicate which element of) arrays(i * numBricksX) +adds two numbers together or concatenates Strings together a]brackets are typically used to declare, initialize and index (indicate which element of) arrays.setScale(0.05);
164 canvas.addSprite(bricks[brackets are typically used to declare, initialize and index (indicate which element of) arrays(i * numBricksX) +adds two numbers together or concatenates Strings together a]brackets are typically used to declare, initialize and index (indicate which element of) arrays);
165 frame.addSprite(bricks[brackets are typically used to declare, initialize and index (indicate which element of) arrays(i * numBricksX) +adds two numbers together or concatenates Strings together a]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 }close braces end code blocks and must match an earlier open brace
168 brickAmount =this assignment operator makes the left side equal to the right side bricks.length;
169 }close braces end code blocks and must match an earlier open brace
170
171 /**Creates the power ups*/
172 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value makePowerUps()
173 {open braces start code blocks and must be matched with a close brace
174 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 powerUpInt =this assignment operator makes the left side equal to the right side 0; powerUpInt < powerUps.length; powerUpInt++this is the increment operator, which increases the variable by 1)
175 {open braces start code blocks and must be matched with a close brace
176 powerUps[brackets are typically used to declare, initialize and index (indicate which element of) arrayspowerUpInt]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 OvalSprite(1, 1);
177 powerUps[brackets are typically used to declare, initialize and index (indicate which element of) arrayspowerUpInt]brackets are typically used to declare, initialize and index (indicate which element of) arrays.setColor(brickColor[brackets are typically used to declare, initialize and index (indicate which element of) arrayspowerUpInt]brackets are typically used to declare, initialize and index (indicate which element of) arrays);
178 powerUps[brackets are typically used to declare, initialize and index (indicate which element of) arrayspowerUpInt]brackets are typically used to declare, initialize and index (indicate which element of) arrays.setScale(.025);
179 }close braces end code blocks and must match an earlier open brace
180 }close braces end code blocks and must match an earlier open brace
181
182 /**Makes the sides and the ceiling*/
183 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value makeLevelBoundaries()
184 {open braces start code blocks and must be matched with a close brace
185 makeDeadArea();
186 makeTopCeiling();
187 makeLeftWall();
188 makeRightWall();
189 }close braces end code blocks and must match an earlier open brace
190
191 /**Creates the bottom boundary.*/
192 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value makeDeadArea()
193 {open braces start code blocks and must be matched with a close brace
194 deadArea[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(20, 1);
195 deadArea[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, 20);
196 deadArea[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(20, 1);
197 deadArea[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(1, 20);
198 deadArea[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, 1.1);
199 deadArea[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);
200 deadArea[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);
201 deadArea[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(1.1, .5);
202 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 areaInt =this assignment operator makes the left side equal to the right side 0; areaInt < deadArea.length; areaInt++this is the increment operator, which increases the variable by 1)
203 {open braces start code blocks and must be matched with a close brace
204 deadArea[brackets are typically used to declare, initialize and index (indicate which element of) arraysareaInt]brackets are typically used to declare, initialize and index (indicate which element of) arrays.setScale(2);
205 deadArea[brackets are typically used to declare, initialize and index (indicate which element of) arraysareaInt]brackets are typically used to declare, initialize and index (indicate which element of) arrays.setColor(Color.red);
206 canvas.addSprite(deadArea[brackets are typically used to declare, initialize and index (indicate which element of) arraysareaInt]brackets are typically used to declare, initialize and index (indicate which element of) arrays);
207 frame.addSprite(deadArea[brackets are typically used to declare, initialize and index (indicate which element of) arraysareaInt]brackets are typically used to declare, initialize and index (indicate which element of) arrays);
208 }close braces end code blocks and must match an earlier open brace
209 }close braces end code blocks and must match an earlier open brace
210
211 /**Creates the top boundary.*/
212 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value makeTopCeiling()
213 {open braces start code blocks and must be matched with a close brace
214 topCeiling =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor OvalSprite(10, .5);
215 topCeiling.setLocation(.5, .15);
216 topCeiling.setScale(2);
217 canvas.addSprite(topCeiling);
218 frame.addSprite(topCeiling);
219 }close braces end code blocks and must match an earlier open brace
220
221 /**Creates the left boundary.*/
222 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value makeLeftWall()
223 {open braces start code blocks and must be matched with a close brace
224 leftWall =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor OvalSprite(1, 12);
225 leftWall.setLocation(startXCoord / 4.5, .5);
226 leftWall.setScale(1.2);
227 canvas.addSprite(leftWall);
228 frame.addSprite(leftWall);
229 }close braces end code blocks and must match an earlier open brace
230
231 /**Creates the right boundary.*/
232 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value makeRightWall()
233 {open braces start code blocks and must be matched with a close brace
234 rightWall =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor OvalSprite(1, 12);
235 rightWall.setLocation(1 - startXCoord / 4.5, .5);
236 rightWall.setScale(1.2);
237 canvas.addSprite(rightWall);
238 frame.addSprite(rightWall);
239 }close braces end code blocks and must match an earlier open brace
240
241 /**Makes the paddle*/
242 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value makePaddle()
243 {open braces start code blocks and must be matched with a close brace
244 paddle =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor Sprite(newnew is used to create objects by calling the constructor java.awt.geom.RoundRectangle2D.Double(0, 0, 5, 1, 1,
245 1));
246 //paddle.visible();
247 //paddle.setShape(new java.awt.geom.RoundRectangle2D.Double(0, 0, 5, 1, 1,
248 // 1));
249 paddle.setLocation(.5, .8);
250 paddle.setScale(.2);
251 canvas.addSprite(paddle);
252 frame.addSprite(paddle);
253 makeMarker();
254 }close braces end code blocks and must match an earlier open brace
255
256 /**Creates the marker forfor is a looping structure for repeatedly executing a block of code the rotation*/
257 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value makeMarker()
258 {open braces start code blocks and must be matched with a close brace
259 marker[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, 1);
260 marker[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(paddle.getLocation());
261 marker[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, 1);
262 marker[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, .1);
263 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 markerInt =this assignment operator makes the left side equal to the right side 0; markerInt < marker.length; markerInt++this is the increment operator, which increases the variable by 1)
264 {open braces start code blocks and must be matched with a close brace
265 marker[brackets are typically used to declare, initialize and index (indicate which element of) arraysmarkerInt]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);
266 canvas.addSprite(marker[brackets are typically used to declare, initialize and index (indicate which element of) arraysmarkerInt]brackets are typically used to declare, initialize and index (indicate which element of) arrays);
267 frame.addSprite(marker[brackets are typically used to declare, initialize and index (indicate which element of) arraysmarkerInt]brackets are typically used to declare, initialize and index (indicate which element of) arrays);
268 }close braces end code blocks and must match an earlier open brace
269 }close braces end code blocks and must match an earlier open brace
270
271 /**Makes the ball*/
272 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value makeBall(intint is the type for whole numbers and it is short for integer ballInt)
273 {open braces start code blocks and must be matched with a close brace
274 whilewhile is a looping structure for executing code repeatedly (ball.size() <=this evaluates to true if the left side is not more than the right side ballInt)
275 {open braces start code blocks and must be matched with a close brace
276 ball.add(newnew is used to create objects by calling the constructor OvalSprite(1, 1));
277 ball.get(ballInt).setLocation(.5, .6);
278 ball.get(ballInt).setScale(.025);
279 makeBallTracker(ballInt);
280 canvas.addSprite(ball.get(ballInt));
281 }close braces end code blocks and must match an earlier open brace
282 }close braces end code blocks and must match an earlier open brace
283
284 /**Creates the score portion of the text.*/
285 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value makeScoreText()
286 {open braces start code blocks and must be matched with a close brace
287 canvas.removeSprite(scoreText);
288 scoreText =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);
289 scoreText.setLocation(.7, .05);
290 scoreText.setColor(Color.WHITE);
291 scoreText.setScale(0.2);
292 canvas.addSprite(scoreText);
293 frame.addSprite(scoreText);
294 }close braces end code blocks and must match an earlier open brace
295
296 /**Creates the lives portion of the text.*/
297 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value makeLivesText()
298 {open braces start code blocks and must be matched with a close brace
299 canvas.removeSprite(livesText);
300 livesText =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 together lives);
301 livesText.setLocation(0.3, .05);
302 livesText.setColor(Color.WHITE);
303 livesText.setScale(0.2);
304 canvas.addSprite(livesText);
305 frame.addSprite(livesText);
306 }close braces end code blocks and must match an earlier open brace
307
308 /**Creates the tracker forfor is a looping structure for repeatedly executing a block of code the ball*/
309 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value makeBallTracker(intint is the type for whole numbers and it is short for integer ballInt)
310 {open braces start code blocks and must be matched with a close brace
311 ifif executes the next statement only if the condition in parenthesis evaluates to true (ball.get(ballInt).getTracker() ==this is the comparison operator which evaluates to true if both sides are the same nullnull is the value used to refer to a non-existant object &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 &&) ball.get(ballInt) !=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)
312 {open braces start code blocks and must be matched with a close brace
313 ballTracker.add(newnew is used to create objects by calling the constructor ProjectileTracker(0.1, -.25));
314 ball.get(ballInt).setTracker(ballTracker.get(ballInt));
315 }close braces end code blocks and must match an earlier open brace
316 }close braces end code blocks and must match an earlier open brace
317
318 /**Removes all Sprites then remakes the game.*/
319 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value resetGame()
320 {open braces start code blocks and must be matched with a close brace
321 frame.setRotation(0.00);
322 canvas.removeAllSprites();
323 ball.removeAll(ball);
324 ballTracker.removeAll(ballTracker);
325 lengthBall =this assignment operator makes the left side equal to the right side 1;
326 makeSprites();
327 }close braces end code blocks and must match an earlier open brace
328
329 /**Color Change forfor is a looping structure for repeatedly executing a block of code boundaries every frame*/
330 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value randomColorBound()
331 {open braces start code blocks and must be matched with a close brace
332 leftWall.setColor(newnew is used to create objects by calling the constructor Color(random.nextInt()));
333 rightWall.setColor(leftWall.getColor());
334 topCeiling.setColor(leftWall.getColor());
335 ball.get(0).setColor(newnew is used to create objects by calling the constructor Color(random.nextInt()));
336 }close braces end code blocks and must match an earlier open brace
337
338 /**Sets the resetText ifif executes the next statement only if the condition in parenthesis evaluates to true game over.*/
339 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value makeResetText()
340 {open braces start code blocks and must be matched with a close brace
341 resetText =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor StringSprite(
342 "Game Over\nPress r to reset the game.");
343 resetText.setScale(0.4);
344 resetText.setColor(Color.WHITE);
345 resetText.setLocation(.5, .5);
346 canvas.addSprite(resetText);
347 gameOver =this assignment operator makes the left side equal to the right side truetrue is the boolean value that is the opposite of false;
348 }close braces end code blocks and must match an earlier open brace
349
350 /**Watches ifif executes the next statement only if the condition in parenthesis evaluates to true the player presses r to reset after game over.*/
351 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value resetWatch()
352 {open braces start code blocks and must be matched with a close brace
353 ifif executes the next statement only if the condition in parenthesis evaluates to true (gameOver ==this is the comparison operator which evaluates to true if both sides are the same truetrue is the boolean value that is the opposite of false &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')
354 {open braces start code blocks and must be matched with a close brace
355 gameOver =this assignment operator makes the left side equal to the right side falsefalse is a value for the boolean type and means not true;
356 resetGame();
357 lives =this assignment operator makes the left side equal to the right side 5;
358 }close braces end code blocks and must match an earlier open brace
359 }close braces end code blocks and must match an earlier open brace
360
361 /**If ball goes under the paddle, lose a life and reset the ball's location*/
362 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value death()
363 {open braces start code blocks and must be matched with a close brace
364 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 areaInt =this assignment operator makes the left side equal to the right side 0; areaInt < deadArea.length; areaInt++this is the increment operator, which increases the variable by 1)
365 {open braces start code blocks and must be matched with a close brace
366 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 ballInt =this assignment operator makes the left side equal to the right side 0; ballInt < ball.size(); ballInt++this is the increment operator, which increases the variable by 1)
367 {open braces start code blocks and must be matched with a close brace
368 ifif executes the next statement only if the condition in parenthesis evaluates to true (ball.get(ballInt).intersects(deadArea[brackets are typically used to declare, initialize and index (indicate which element of) arraysareaInt]brackets are typically used to declare, initialize and index (indicate which element of) arrays) &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 &&) gameOver ==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)
369 {open braces start code blocks and must be matched with a close brace
370 canvas.removeSprite(ball.get(ballInt));
371 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 powerInt =this assignment operator makes the left side equal to the right side 0; powerInt < powerUps.length; powerInt++this is the increment operator, which increases the variable by 1)
372 {open braces start code blocks and must be matched with a close brace
373 canvas.removeSprite(powerUps[brackets are typically used to declare, initialize and index (indicate which element of) arrayspowerInt]brackets are typically used to declare, initialize and index (indicate which element of) arrays);
374 }close braces end code blocks and must match an earlier open brace
375 }close braces end code blocks and must match an earlier open brace
376 }close braces end code blocks and must match an earlier open brace
377 ifif executes the next statement only if the condition in parenthesis evaluates to true (ball.get(0).intersects(deadArea[brackets are typically used to declare, initialize and index (indicate which element of) arraysareaInt]brackets are typically used to declare, initialize and index (indicate which element of) arrays) &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 &&) gameOver ==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)
378 {open braces start code blocks and must be matched with a close brace
379 resetBall();
380 breakoutToggle =this assignment operator makes the left side equal to the right side falsefalse is a value for the boolean type and means not true;
381 lives--this is the decrement operator, which decreases the variable by 1;
382 livesText.setText("Lives: " +adds two numbers together or concatenates Strings together lives);
383 }close braces end code blocks and must match an earlier open brace
384
385 }close braces end code blocks and must match an earlier open brace
386 }close braces end code blocks and must match an earlier open brace
387
388 /**Resets the ball location when it dies*/
389 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value resetBall()
390 {open braces start code blocks and must be matched with a close brace
391 ifif executes the next statement only if the condition in parenthesis evaluates to true (lives > 1)
392 {open braces start code blocks and must be matched with a close brace
393 ball.get(0).setLocation(.5, .5);
394 ball.removeAll(ball);
395 ballTracker.removeAll(ballTracker);
396 lengthBall =this assignment operator makes the left side equal to the right side 1;
397 makeBall(0);
398 }close braces end code blocks and must match an earlier open brace
399 elseelse is what happens when the if condition is false
400 {open braces start code blocks and must be matched with a close brace
401 makeResetText();
402 }close braces end code blocks and must match an earlier open brace
403 }close braces end code blocks and must match an earlier open brace
404
405 /**Sends the ball and the surface to ballBounce()*/
406 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value boundaryBounce()
407 {open braces start code blocks and must be matched with a close brace
408 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 ballInt =this assignment operator makes the left side equal to the right side 0; ballInt < ball.size(); ballInt++this is the increment operator, which increases the variable by 1)
409 {open braces start code blocks and must be matched with a close brace
410 ifif executes the next statement only if the condition in parenthesis evaluates to true (ball.get(ballInt).intersects(paddle))
411 {open braces start code blocks and must be matched with a close brace
412 ballBounce(paddle, ballInt);
413 }close braces end code blocks and must match an earlier open brace
414 ifif executes the next statement only if the condition in parenthesis evaluates to true (ball.get(ballInt).intersects(topCeiling))
415 {open braces start code blocks and must be matched with a close brace
416 ballBounce(topCeiling, ballInt);
417 //avoidThrough(topCeiling, ballInt);
418 }close braces end code blocks and must match an earlier open brace
419 ifif executes the next statement only if the condition in parenthesis evaluates to true (ball.get(ballInt).intersects(leftWall))
420 {open braces start code blocks and must be matched with a close brace
421 ballBounce(leftWall, ballInt);
422 //avoidThrough(leftWall, ballInt);
423 }close braces end code blocks and must match an earlier open brace
424 ifif executes the next statement only if the condition in parenthesis evaluates to true (ball.get(ballInt).intersects(rightWall))
425 {open braces start code blocks and must be matched with a close brace
426 ballBounce(rightWall, ballInt);
427 //avoidThrough(rightWall, ballInt);
428 }close braces end code blocks and must match an earlier open brace
429 }close braces end code blocks and must match an earlier open brace
430 }close braces end code blocks and must match an earlier open brace
431
432 /**A hack so it doesn't go through the walls*/
433 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value avoidThrough(Sprite bound, intint is the type for whole numbers and it is short for integer ballInt)
434 {open braces start code blocks and must be matched with a close brace
435 whilewhile is a looping structure for executing code repeatedly (ball.get(ballInt).intersects(bound) &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 &&)
436 bound !=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)
437 {open braces start code blocks and must be matched with a close brace
438 ballTracker.get(ballInt).advanceTime(0.001);
439 }close braces end code blocks and must match an earlier open brace
440 }close braces end code blocks and must match an earlier open brace
441
442 /**When ball hits a brick, add score, remove brick, bounce ball*/
443 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value brickBounce()
444 {open braces start code blocks and must be matched with a close brace
445 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 brickInt =this assignment operator makes the left side equal to the right side 0; brickInt < bricks.length; brickInt++this is the increment operator, which increases the variable by 1)
446 {open braces start code blocks and must be matched with a close brace
447 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 ballInt =this assignment operator makes the left side equal to the right side 0; ballInt < ball.size(); ballInt++this is the increment operator, which increases the variable by 1)
448 {open braces start code blocks and must be matched with a close brace
449 ifif executes the next statement only if the condition in parenthesis evaluates to true (ball.get(ballInt).intersects(bricks[brackets are typically used to declare, initialize and index (indicate which element of) arraysbrickInt]brackets are typically used to declare, initialize and index (indicate which element of) arrays) &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 &&)
450 bricks[brackets are typically used to declare, initialize and index (indicate which element of) arraysbrickInt]brackets are typically used to declare, initialize and index (indicate which element of) arrays !=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)
451 {open braces start code blocks and must be matched with a close brace
452 score++this is the increment operator, which increases the variable by 1;
453 scoreText.setText("Score: " +adds two numbers together or concatenates Strings together score);
454 ifif executes the next statement only if the condition in parenthesis evaluates to true (breakoutToggle ==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)
455 {open braces start code blocks and must be matched with a close brace
456 ballBounce(bricks[brackets are typically used to declare, initialize and index (indicate which element of) arraysbrickInt]brackets are typically used to declare, initialize and index (indicate which element of) arrays, ballInt);
457 }close braces end code blocks and must match an earlier open brace
458 brickColorChange(brickInt);
459 }close braces end code blocks and must match an earlier open brace
460 }close braces end code blocks and must match an earlier open brace
461 }close braces end code blocks and must match an earlier open brace
462 }close braces end code blocks and must match an earlier open brace
463
464 /**Changes the color of the brick to one less. If blue, remove brick.*/
465 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value brickColorChange(intint is the type for whole numbers and it is short for integer brickInt)
466 {open braces start code blocks and must be matched with a close brace
467 ifif executes the next statement only if the condition in parenthesis evaluates to true (bricks[brackets are typically used to declare, initialize and index (indicate which element of) arraysbrickInt]brackets are typically used to declare, initialize and index (indicate which element of) arrays.getColor() ==this is the comparison operator which evaluates to true if both sides are the same brickColor[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 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 &&)
468 bricks[brackets are typically used to declare, initialize and index (indicate which element of) arraysbrickInt]brackets are typically used to declare, initialize and index (indicate which element of) arrays.isVisible())
469 {open braces start code blocks and must be matched with a close brace
470 powerCreate(random.nextInt(powerChance), brickInt);
471 canvas.removeSprite(bricks[brackets are typically used to declare, initialize and index (indicate which element of) arraysbrickInt]brackets are typically used to declare, initialize and index (indicate which element of) arrays);
472 brickAmount--this is the decrement operator, which decreases the variable by 1;
473 bricks[brackets are typically used to declare, initialize and index (indicate which element of) arraysbrickInt]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(0, 0);
474 }close braces end code blocks and must match an earlier open brace
475 elseelse is what happens when the if condition is false
476 {open braces start code blocks and must be matched with a close brace
477 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 colorHit =this assignment operator makes the left side equal to the right side 0; colorHit < numBricksY; colorHit++this is the increment operator, which increases the variable by 1)
478 {open braces start code blocks and must be matched with a close brace
479 ifif executes the next statement only if the condition in parenthesis evaluates to true (bricks[brackets are typically used to declare, initialize and index (indicate which element of) arraysbrickInt]brackets are typically used to declare, initialize and index (indicate which element of) arrays.getColor() ==this is the comparison operator which evaluates to true if both sides are the same brickColor[brackets are typically used to declare, initialize and index (indicate which element of) arrayscolorHit]brackets are typically used to declare, initialize and index (indicate which element of) arrays)
480 {open braces start code blocks and must be matched with a close brace
481 bricks[brackets are typically used to declare, initialize and index (indicate which element of) arraysbrickInt]brackets are typically used to declare, initialize and index (indicate which element of) arrays.setColor(brickColor[brackets are typically used to declare, initialize and index (indicate which element of) arrayscolorHit - 1]brackets are typically used to declare, initialize and index (indicate which element of) arrays);
482 }close braces end code blocks and must match an earlier open brace
483 }close braces end code blocks and must match an earlier open brace
484 }close braces end code blocks and must match an earlier open brace
485 }close braces end code blocks and must match an earlier open brace
486
487 /**Creates the power up based on which number is selected*/
488 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value powerCreate(intint is the type for whole numbers and it is short for integer chance, intint is the type for whole numbers and it is short for integer brickInt)
489 {open braces start code blocks and must be matched with a close brace
490 intint is the type for whole numbers and it is short for integer powerNum =this assignment operator makes the left side equal to the right side random.nextInt(powerUps.length);
491 ifif executes the next statement only if the condition in parenthesis evaluates to true (chance +adds two numbers together or concatenates Strings together 1 ==this is the comparison operator which evaluates to true if both sides are the same powerChance)
492 {open braces start code blocks and must be matched with a close brace
493 powerUps[brackets are typically used to declare, initialize and index (indicate which element of) arrayspowerNum]brackets are typically used to declare, initialize and index (indicate which element of) arrays.setTracker(powerUpTracker);
494 powerUps[brackets are typically used to declare, initialize and index (indicate which element of) arrayspowerNum]brackets are typically used to declare, initialize and index (indicate which element of) arrays.setLocation(bricks[brackets are typically used to declare, initialize and index (indicate which element of) arraysbrickInt]brackets are typically used to declare, initialize and index (indicate which element of) arrays.getLocation());
495 canvas.addSprite(powerUps[brackets are typically used to declare, initialize and index (indicate which element of) arrayspowerNum]brackets are typically used to declare, initialize and index (indicate which element of) arrays);
496 }close braces end code blocks and must match an earlier open brace
497 }close braces end code blocks and must match an earlier open brace
498
499 /**Sets it so the ball bounces when it hits the paddle or boundary*/
500 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value ballBounce(Sprite surface, intint is the type for whole numbers and it is short for integer ballInt)
501 {open braces start code blocks and must be matched with a close brace
502 normal =this assignment operator makes the left side equal to the right side Sprite.getNormalVector(surface.getShape(),
503 ball.get(ballInt).getShape());
504 ballTracker.get(ballInt).bounce(normal);
505 }close braces end code blocks and must match an earlier open brace
506
507 /**If player wins, game is over*/
508 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value win()
509 {open braces start code blocks and must be matched with a close brace
510 ifif executes the next statement only if the condition in parenthesis evaluates to true (brickAmount ==this is the comparison operator which evaluates to true if both sides are the same 0)
511 {open braces start code blocks and must be matched with a close brace
512 gameOver =this assignment operator makes the left side equal to the right side truetrue is the boolean value that is the opposite of false;
513 makeResetText();
514 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 ballInt =this assignment operator makes the left side equal to the right side 0; ballInt < ball.size(); ballInt++this is the increment operator, which increases the variable by 1)
515 {open braces start code blocks and must be matched with a close brace
516 ball.get(ballInt).setVisible(falsefalse is a value for the boolean type and means not true);
517 }close braces end code blocks and must match an earlier open brace
518 }close braces end code blocks and must match an earlier open brace
519 }close braces end code blocks and must match an earlier open brace
520
521 /**Watches ifif executes the next statement only if the condition in parenthesis evaluates to true the paddle touches the power up*/
522 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value watchPower()
523 {open braces start code blocks and must be matched with a close brace
524 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 powerInt =this assignment operator makes the left side equal to the right side 0; powerInt < powerUps.length; powerInt++this is the increment operator, which increases the variable by 1)
525 {open braces start code blocks and must be matched with a close brace
526 ifif executes the next statement only if the condition in parenthesis evaluates to true (paddle.intersects(powerUps[brackets are typically used to declare, initialize and index (indicate which element of) arrayspowerInt]brackets are typically used to declare, initialize and index (indicate which element of) arrays) &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 &&)
527 powerUps[brackets are typically used to declare, initialize and index (indicate which element of) arrayspowerInt]brackets are typically used to declare, initialize and index (indicate which element of) arrays.isVisible())
528 {open braces start code blocks and must be matched with a close brace
529 canvas.removeSprite(powerUps[brackets are typically used to declare, initialize and index (indicate which element of) arrayspowerInt]brackets are typically used to declare, initialize and index (indicate which element of) arrays);
530 powerCase(powerInt);
531 }close braces end code blocks and must match an earlier open brace
532 ifif executes the next statement only if the condition in parenthesis evaluates to true (deadArea[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(powerUps[brackets are typically used to declare, initialize and index (indicate which element of) arrayspowerInt]brackets are typically used to declare, initialize and index (indicate which element of) arrays))
533 {open braces start code blocks and must be matched with a close brace
534 canvas.removeSprite(powerUps[brackets are typically used to declare, initialize and index (indicate which element of) arrayspowerInt]brackets are typically used to declare, initialize and index (indicate which element of) arrays);
535 }close braces end code blocks and must match an earlier open brace
536 }close braces end code blocks and must match an earlier open brace
537 }close braces end code blocks and must match an earlier open brace
538
539 /**All of the cases forfor is a looping structure for repeatedly executing a block of code which power up is picked up*/
540 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value powerCase(intint is the type for whole numbers and it is short for integer powerInt)
541 {open braces start code blocks and must be matched with a close brace
542 ArrayList<Point2D.Double> powerSpeed =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor ArrayList<Point2D.Double>();
543 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 speedInt =this assignment operator makes the left side equal to the right side 0; speedInt < ballTracker.size(); speedInt++this is the increment operator, which increases the variable by 1)
544 {open braces start code blocks and must be matched with a close brace
545 powerSpeed.add(ballTracker.get(speedInt).getVelocity());
546 switchswitch is used with case for multiple alternatives (like if/else if...) (powerInt)
547 {open braces start code blocks and must be matched with a close brace
548 casecase is used with switch for multiple alternatives (like if/else if...) 0:
549 increaseSpeed(powerSpeed.get(speedInt), speedInt);
550 breakbreak terminates the loop immediately;
551 casecase is used with switch for multiple alternatives (like if/else if...) 1:
552 decreaseSpeed(powerSpeed.get(speedInt), speedInt);
553 breakbreak terminates the loop immediately;
554 casecase is used with switch for multiple alternatives (like if/else if...) 2:
555 multiBall();
556 breakbreak terminates the loop immediately;
557 casecase is used with switch for multiple alternatives (like if/else if...) 3:
558 breakOut();
559 breakbreak terminates the loop immediately;
560 casecase is used with switch for multiple alternatives (like if/else if...) 4:
561 wider();
562 breakbreak terminates the loop immediately;
563 casecase is used with switch for multiple alternatives (like if/else if...) 5:
564 increaseLife();
565 breakbreak terminates the loop immediately;
566 casecase is used with switch for multiple alternatives (like if/else if...) 6:
567 increaseScore();
568 breakbreak terminates the loop immediately;
569 }close braces end code blocks and must match an earlier open brace
570 }close braces end code blocks and must match an earlier open brace
571
572 }close braces end code blocks and must match an earlier open brace
573
574 /**Increases the speed of the ball*/
575 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value increaseSpeed(Point2D.Double powerSpeed, intint is the type for whole numbers and it is short for integer speedInt)
576 {open braces start code blocks and must be matched with a close brace
577 canvas.removeSprite(powerUps[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);
578 powerUps[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, 0);
579 powerUps[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(nullnull is the value used to refer to a non-existant object);
580 powerSpeed.x +=this increases the variable on the left by the value on the right .05;
581 powerSpeed.y +=this increases the variable on the left by the value on the right .05;
582 ballTracker.get(speedInt).setVelocity(powerSpeed);
583 }close braces end code blocks and must match an earlier open brace
584
585 /**Dereases the speed of the ball*/
586 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value decreaseSpeed(Point2D.Double powerSpeed, intint is the type for whole numbers and it is short for integer speedInt)
587 {open braces start code blocks and must be matched with a close brace
588 canvas.removeSprite(powerUps[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);
589 powerUps[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(0, 0);
590 powerUps[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.setTracker(nullnull is the value used to refer to a non-existant object);
591 powerSpeed.x -=this decreases the variable on the left by the value on the right .05;
592 powerSpeed.y -=this decreases the variable on the left by the value on the right .05;
593 ballTracker.get(speedInt).setVelocity(powerSpeed);
594 }close braces end code blocks and must match an earlier open brace
595
596 /**Increases the number of balls in play*/
597 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value multiBall()
598 {open braces start code blocks and must be matched with a close brace
599 ifif executes the next statement only if the condition in parenthesis evaluates to true (powerUps[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 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 &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 &&) powerUps[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.isVisible())
600 {open braces start code blocks and must be matched with a close brace
601 canvas.removeSprite(powerUps[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);
602 powerUps[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(0, 0);
603 powerUps[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.setTracker(nullnull is the value used to refer to a non-existant object);
604 powerUps[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 Sprite();
605 lengthBall =this assignment operator makes the left side equal to the right side 2;
606 makeBall(lengthBall - 1);
607 }close braces end code blocks and must match an earlier open brace
608 }close braces end code blocks and must match an earlier open brace
609
610 /**Increases the width of the paddle*/
611 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value wider()
612 {open braces start code blocks and must be matched with a close brace
613 canvas.removeSprite(paddle);
614 powerUps[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.setLocation(0, 0);
615 powerUps[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.setTracker(nullnull is the value used to refer to a non-existant object);
616 canvas.removeSprite(powerUps[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);
617 paddle =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor Sprite(newnew is used to create objects by calling the constructor java.awt.geom.RoundRectangle2D.Double(0, 0, 10, 1,
618 1, 1));
619 paddle.setRotation(frame.getRotation());
620 //paddle.setShape(new java.awt.geom.RoundRectangle2D.Double(0, 0, 10, 1,
621 // 1, 1));
622 paddle.setScale(.4);
623 paddle.setLocation(paddle.getLocation());
624 canvas.addSprite(paddle);
625 frame.addSprite(paddle);
626 }close braces end code blocks and must match an earlier open brace
627
628 /**Increases the number of lives*/
629 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value increaseLife()
630 {open braces start code blocks and must be matched with a close brace
631 lives++this is the increment operator, which increases the variable by 1;
632 livesText.setText("Lives: " +adds two numbers together or concatenates Strings together lives);
633 canvas.removeSprite(powerUps[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);
634 powerUps[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.setLocation(0, 0);
635 powerUps[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.setTracker(nullnull is the value used to refer to a non-existant object);
636 }close braces end code blocks and must match an earlier open brace
637
638 /**Increases the score*/
639 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value increaseScore()
640 {open braces start code blocks and must be matched with a close brace
641 score +=this increases the variable on the left by the value on the right 25;
642 scoreText.setText("Score: " +adds two numbers together or concatenates Strings together score);
643 canvas.removeSprite(powerUps[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);
644 powerUps[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.setLocation(0, 0);
645 powerUps[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.setTracker(nullnull is the value used to refer to a non-existant object);
646 }close braces end code blocks and must match an earlier open brace
647
648 /**Allows the ball to breakthrough bricks instead of bouncing*/
649 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value breakOut()
650 {open braces start code blocks and must be matched with a close brace
651 canvas.removeSprite(powerUps[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);
652 powerUps[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, 0);
653 powerUps[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(nullnull is the value used to refer to a non-existant object);
654 breakoutToggle =this assignment operator makes the left side equal to the right side truetrue is the boolean value that is the opposite of false;
655 scheduleRelative(newnew is used to create objects by calling the constructor BreakoutToggle(breakoutToggle), 30);
656 }close braces end code blocks and must match an earlier open brace
657
658 /**Controls the velocity of the ball*/
659 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value velocityControl(doubledouble is the type for numbers that can contain decimal fractions timePassed)
660 {open braces start code blocks and must be matched with a close brace
661 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 trackInt =this assignment operator makes the left side equal to the right side 0; trackInt < ballTracker.size(); trackInt++this is the increment operator, which increases the variable by 1)
662 {open braces start code blocks and must be matched with a close brace
663 Point2D.Double ballV[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 =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor Point2D.Double[brackets are typically used to declare, initialize and index (indicate which element of) arraysballTracker.size()]brackets are typically used to declare, initialize and index (indicate which element of) arrays;
664 ballV[brackets are typically used to declare, initialize and index (indicate which element of) arraystrackInt]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 ballTracker.get(trackInt).getVelocity();
665 ballV[brackets are typically used to declare, initialize and index (indicate which element of) arraystrackInt]brackets are typically used to declare, initialize and index (indicate which element of) arrays.y +=this increases the variable on the left by the value on the right .1 * timePassed;
666 ballTracker.get(trackInt).setVelocity(ballV[brackets are typically used to declare, initialize and index (indicate which element of) arraystrackInt]brackets are typically used to declare, initialize and index (indicate which element of) arrays);
667 }close braces end code blocks and must match an earlier open brace
668 }close braces end code blocks and must match an earlier open brace
669
670 /**Slowly rotates the frame*/
671 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value frameRotate()
672 {open braces start code blocks and must be matched with a close brace
673 frame.setCenter(.5, .5);
674 frame.rotate(0.01);
675 }close braces end code blocks and must match an earlier open brace
676
677 /**handle input and game events*/
678 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)
679 {open braces start code blocks and must be matched with a close brace
680 resetWatch();
681 death();
682 powerUpTracker.setVelocityDirection(frame.getRotation() +adds two numbers together or concatenates Strings together 3.14 / 2);
683 ifif executes the next statement only if the condition in parenthesis evaluates to true (gameOver ==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)
684 {open braces start code blocks and must be matched with a close brace
685 Point2D.Double mouseLoc =this assignment operator makes the left side equal to the right side getPlayer().getMouse().getLocation();
686 paddle.setLocation(( -.5 +adds two numbers together or concatenates Strings together mouseLoc.getX()) *
687 Math.cos(frame.getRotation()) +adds two numbers together or concatenates Strings together
688 marker[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.getLocation().x,
689 ( -.5 +adds two numbers together or concatenates Strings together mouseLoc.getX()) *
690 Math.sin(frame.getRotation()) +adds two numbers together or concatenates Strings together
691 marker[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.getLocation().y);
692 velocityControl(timePassed);
693 frameRotate();
694 randomColorBound();
695 watchPower();
696 boundaryBounce();
697 brickBounce();
698 win();
699 }close braces end code blocks and must match an earlier open brace
700 }close braces end code blocks and must match an earlier open brace
701
702 /**Class to create and Image a specified time after a click.*/
703 privateprivate is used to restrict access to the current class only classclass is a group of fields and methods used for making objects BreakoutToggle implementsimplements means providing method bodies for the methods declared in the corresponding interface Alarm
704 {open braces start code blocks and must be matched with a close brace
705 privateprivate is used to restrict access to the current class only booleanboolean is a type that is either true or false breakoutToggle;
706 publicpublic is used to indicate unrestricted access (any other class can have access) BreakoutToggle(booleanboolean is a type that is either true or false toggle)
707 {open braces start code blocks and must be matched with a close brace
708 breakoutToggle =this assignment operator makes the left side equal to the right side toggle;
709 }close braces end code blocks and must match an earlier open brace
710
711 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value alarm()
712 {open braces start code blocks and must be matched with a close brace
713 breakoutToggle =this assignment operator makes the left side equal to the right side falsefalse is a value for the boolean type and means not true;
714 }close braces end code blocks and must match an earlier open brace
715 }close braces end code blocks and must match an earlier open brace
716
717 }close braces end code blocks and must match an earlier open brace
|