class Ball { //The class for the ball
//Initialization of the ball's variables
PVector ballLocation; //The location of the ball
PVector ballSpeed; //The speed of the ball
color ballColor = color(255); //The color of the ball - defaults as white
int canNextBallBeHitTimer = 0; //The time before the next hit is allowed - this is to stop a glitch that lets a ball hit more then one brick at a time
Ball(float ballSpawnLocationX, float ballSpawnLocationY, float inputBallSpeedX, float inputBallSpeedY) { //Takes the nessessary inputs and creates a new ball with these properties
//Declaration of the ball's variables
this.ballLocation = new PVector(ballSpawnLocationX, ballSpawnLocationY); //Sets the inputed location to the new ball
this.ballSpeed = new PVector(inputBallSpeedX, inputBallSpeedY); //Sets the speed of the ball
}
void renderBall(int ballNumber) { //Renders the ball
//Movement of the ball
if (!pauseState) { //If the game isn't paused
this.ballLocation.x += this.ballSpeed.x; //Moves ball horizantally by the horizantal speed
this.ballLocation.y += this.ballSpeed.y; //Moves ball vertically by the vertical speed
}
//Collision of the ball with the walls
if (this.ballLocation.x < BALL_SIZE && this.ballSpeed.x < 0) this.ballSpeed.x = -this.ballSpeed.x; //If the ball moves to the left and hits the left wall, reflect the ball
if (this.ballLocation.x > SCREEN_SIZE - BALL_SIZE && this.ballSpeed.x > 0) this.ballSpeed.x = -this.ballSpeed.x; //If the ball moves to the right and hits the right wall, reflect the ball
if (this.ballLocation.y < BALL_SIZE && this.ballSpeed.y < 0) this.ballSpeed.y = -this.ballSpeed.y; //If the ball moves up and hits the top wall, reflect the ball
if (this.ballLocation.y - BALL_SIZE > SCREEN_SIZE) numBalls.remove(ballNumber); //If the ball goes past the bottom of the screen, remove it
//Collision of the ball with the paddle
if (this.ballLocation.x + BALL_SIZE/2 > playerPaddle.paddleLocation.x //If the ball is right of the left side of the paddle
&& this.ballLocation.x - BALL_SIZE/2 < playerPaddle.paddleLocation.x + paddleSize.x //If the ball is on the left of the right side of the paddle
&& this.ballLocation.y + BALL_SIZE/2 > playerPaddle.paddleLocation.y //If the ball is past the top of the paddle
&& this.ballLocation.y + BALL_SIZE/2 < playerPaddle.paddleLocation.y + paddleSize.y //If the ball is above the bottom of the paddle
&& this.ballSpeed.y > 0) { //If the ball is moving downwards (as to stop a glitch which causes the ball to vibrate when bouncing off the paddle)
if (this.ballLocation.x > playerPaddle.paddleLocation.x + paddleSize.x/2) //If the ball hits on the right side of the paddle
this.ballSpeed.x = dist(playerPaddle.paddleLocation.x + paddleSize.x/2, 0, this.ballLocation.x, 0)/HORIZANTAL_SPEED_SENSITIVITY; //Angle towards the right side in proportion to the distance of the ball with the middle of the paddle
else //If the ball hits on the left side of the paddle
this.ballSpeed.x = -dist(playerPaddle.paddleLocation.x + paddleSize.x/2, 0, this.ballLocation.x, 0)/HORIZANTAL_SPEED_SENSITIVITY; //Angle towards the left side in proportion to the distance of the ball with the middle of the paddle
this.ballSpeed.y = -this.ballSpeed.y; //Reflect the ball vertically
}
//Collision of the ball with a brick
for (int brickNumber = 0; brickNumber < numBricks.size(); brickNumber++) { //Checks all currently rendering bricks
if (this.ballLocation.x + BALL_SIZE/2 >= numBricks.get(brickNumber).brickLocation.x //If the ball's right side is past the left side of the brick
&& this.ballLocation.x - BALL_SIZE/2 <= numBricks.get(brickNumber).brickLocation.x + BRICK_SIZE.x //If the ball's left side is past the right side of the brick
&& this.ballLocation.y + BALL_SIZE/2 >= numBricks.get(brickNumber).brickLocation.y //If the ball's bottom is past the top of the brick
&& this.ballLocation.y - BALL_SIZE/2 <= numBricks.get(brickNumber).brickLocation.y + BRICK_SIZE.y) { //If the ball's top is above the bottom of the brick
if ((this.ballLocation.x < numBricks.get(brickNumber).brickLocation.x && this.ballSpeed.x > 0) //If the ball hits the left side of the brick
|| (this.ballLocation.x > numBricks.get(brickNumber).brickLocation.x + BRICK_SIZE.x && this.ballSpeed.x < 0)) this.ballSpeed.x = -this.ballSpeed.x; //Or if the ball hits the right side of the brick, reflect it back
if ((this.ballLocation.y < numBricks.get(brickNumber).brickLocation.y && this.ballSpeed.y > 0) //If the ball hits the top side of the brick
|| (this.ballLocation.y > numBricks.get(brickNumber).brickLocation.y + BRICK_SIZE.y && this.ballSpeed.y < 0)) this.ballSpeed.y = -this.ballSpeed.y; //Or the ball hits the bottom of the brick, reflect the ball vertically
if (this.canNextBallBeHitTimer <= 0) { //If the timer allows another block to be destroyed
//The power-up drop code of the brick
if (int(random(CHANCE_OF_POWER_UP)) == 0) //If the random chance happens in which a power-up should be dropped
numPowerUps.add(new PowerUp(numBricks.get(brickNumber).brickLocation.x + BRICK_SIZE.x/2,
numBricks.get(brickNumber).brickLocation.y + BRICK_SIZE.y/2)); //Spawns a power-up at that brick's location
this.ballColor = numBricks.get(brickNumber).brickColor; //Transfers the color of the brick to the ball
numBricks.remove(brickNumber); //Removes the hit block if the ball is allowed to destroy a block
this.canNextBallBeHitTimer = MINIMUM_TIME_BEFORE_NEXT_HIT; //Resets the hit timer
}
}
}
if (stickBallToPaddle) //If the ball must be stuck to the paddle
this.ballLocation = new PVector(playerPaddle.paddleLocation.x + paddleSize.x/2, playerPaddle.paddleLocation.y - BALL_SIZE/2); //Move the ball just above the paddle
canNextBallBeHitTimer--; //Decreases the hit timer by one
//Drawing of the ball
fill(this.ballColor); //Colors white
ellipse(this.ballLocation.x, this.ballLocation.y, BALL_SIZE, BALL_SIZE); //Draws the ball
}
}
class Brick { //Class for the bricks
//Initialization of the bricks's variables
PVector brickLocation; //Location of the brick
color brickColor; //The color of the brick
Brick(float brickSpawnLocationX, float brickSpawnLocationY, PVector currentBrickColorScheme) { //Takes neccessary inputs and creates a brick with those properties
this.brickLocation = new PVector(brickSpawnLocationX, brickSpawnLocationY); //Sets the brick to the location of the inputed variables
this.brickColor = color(random(currentBrickColorScheme.x - COLOR_SCHEME_RANGE, currentBrickColorScheme.x + COLOR_SCHEME_RANGE),
random(currentBrickColorScheme.y - COLOR_SCHEME_RANGE, currentBrickColorScheme.y + COLOR_SCHEME_RANGE),
random(currentBrickColorScheme.z - COLOR_SCHEME_RANGE, currentBrickColorScheme.z + COLOR_SCHEME_RANGE)); //Gives the brick a random color based on the current color scheme
}
void renderBrick() { //Renders the brick
//Drawing of the brick
fill(this.brickColor); //Colors the brick color
rect(this.brickLocation.x, this.brickLocation.y, BRICK_SIZE.x, BRICK_SIZE.y); //Draws the brick
}
}
class Paddle { //Class for the paddle
//Initialization of the paddle's variables
PVector paddleLocation; //Location of the paddle
Paddle() { //Creates a new paddle
this.paddleLocation = new PVector(SCREEN_SIZE/2, SCREEN_SIZE - paddleSize.y * 2); //Moves the paddle to the middle of the x-axis, and to just above the bottom of the screen
}
void renderPaddle() { //Method for rendering the paddle
//Movement of the paddle
if (!pauseState) //If the game is not paused
this.paddleLocation.x = mouseX - paddleSize.x / 2; //Moves the paddle to the mouse
//Extended properties of the paddle
if (extendedPaddleTimer > 0) //If the timer states that the paddle should be extended
paddleSize.x = EXTENDED_PADDLE_WIDTH; //Extend the paddle
else
paddleSize.x = CONTRACTED_PADDLE_WIDTH; //Contract the paddle
if (!pauseState) extendedPaddleTimer--; //Decreases the time for extending the paddle if the game is not paused
//Drawing of the paddle
fill(255); //Colors white
rect(this.paddleLocation.x, this.paddleLocation.y, paddleSize.x, paddleSize.y); //Draws the paddle
}
}
class PowerUp { //Class for the power ups
//Initialization of the power up's variables
PVector powerUpLocation; //The location of the power ups
/* PowerUp Type Values
0 = x3 Balls Power-Up
1 = Extended Paddle Power Up*/
int powerUpType; //The type of the power up
PowerUp(float powerUpSpawnLocationX, float powerUpSpawnLocationY) { //Creates a power-up with the inputed proportions
this.powerUpLocation = new PVector(powerUpSpawnLocationX, powerUpSpawnLocationY); //Sets the location to the inputed co-ordinates
this.powerUpType = int(random(TYPES_OF_POWER_UPS)); //Sets the power up type to the inputed power up type
}
void renderPowerUp(int powerUpNumber) { //Renders the power up
//Movement of the power up
this.powerUpLocation.y += POWER_UP_SPEED; //Lowers the power up
//Collision with the bottom wall
if (this.powerUpLocation.y - POWER_UP_SIZE > SCREEN_SIZE) numPowerUps.remove(powerUpNumber); //If the powerup passes the bottom of the screen, remove it
//Collision with the paddle
if (this.powerUpLocation.x + POWER_UP_SIZE/2 > playerPaddle.paddleLocation.x //If the powerup is right of the left side of the paddle
&& this.powerUpLocation.x - POWER_UP_SIZE/2 < playerPaddle.paddleLocation.x + paddleSize.x //If the powerup is on the left of the right side of the paddle
&& this.powerUpLocation.y + POWER_UP_SIZE/2 > playerPaddle.paddleLocation.y //If the powerup is past the top of the paddle
&& this.powerUpLocation.y + POWER_UP_SIZE/2 < playerPaddle.paddleLocation.y + paddleSize.y) { //If the powerup is above the bottom of the paddle
switch(this.powerUpType) { //Checks the power up type
case 0: //If it is a x3 power up
currentAmountOfBalls = numBalls.size(); //Sets the current amount of balls to the size of the arraylist as to not run out of memory in a constant loop due to newly spawned balls
for (int i = 0; i < currentAmountOfBalls; i++) { //For every ball that is on the game...
numBalls.add(new Ball(numBalls.get(i).ballLocation.x, numBalls.get(i).ballLocation.y, numBalls.get(i).ballSpeed.x, -numBalls.get(i).ballSpeed.y)); //Creates a ball going diagonally top-right relative to the ball's direction
numBalls.add(new Ball(numBalls.get(i).ballLocation.x, numBalls.get(i).ballLocation.y, -numBalls.get(i).ballSpeed.x, numBalls.get(i).ballSpeed.y)); //Creates a ball going diagonally bottom-left relative to the ball's direction
numBalls.add(new Ball(numBalls.get(i).ballLocation.x, numBalls.get(i).ballLocation.y, -numBalls.get(i).ballSpeed.x, -numBalls.get(i).ballSpeed.y)); //Creates a ball going diagonally top-left relative to the ball's direction
}
break;
case 1: //If it is an extended paddle power up
extendedPaddleTimer = PADDLE_EXTEND_TIME; //Sets sticky time to maximum sticky time
break;
}
numPowerUps.remove(powerUpNumber); //Remove the power up
}
//Drawing of the power up
fill(colorChangeAnimationColor); //Colors the color animation color
ellipse(this.powerUpLocation.x, this.powerUpLocation.y, POWER_UP_SIZE, POWER_UP_SIZE); //Draws the power up
fill(0);
textFont(HUDfont, SCREEN_SIZE/50); //Sets the text font
switch(this.powerUpType) { //Checks the type of the power up
case 0: //If it is a x3 Power Up
text("3", this.powerUpLocation.x - SCREEN_SIZE/800, this.powerUpLocation.y + SCREEN_SIZE*3/400); //Writes the number 3 on the power up for recognition from the user
break;
case 1: //If it is an extended paddle power up
text("E", this.powerUpLocation.x - SCREEN_SIZE/800, this.powerUpLocation.y + SCREEN_SIZE*3/400); //Writes the letter E on the power up for recognition from the user
break;
}
}
}
/*/---------------
Rainbow Breaker
Made by Simon Hajjar
From 06.03.12
This is a simple program that remakes the famed brick-breaker, which
slight variations on the color scheme. The paddle is controlled by
the mouse, and when clicked, the ball is released, and the game
begins. Furthermore, there are also two added power-ups - the x3
Power Up which multiplies the amount of balls by three, and the
Extended Paddle Power Up, which extends the paddle for a period
of time.
---------------/*/
final int SCREEN_SIZE = 700; //Sets the variables for the width and height
//Variales pertaining to the paddle
Paddle playerPaddle; //Creates the player's paddle
PVector paddleSize = new PVector(SCREEN_SIZE/7, SCREEN_SIZE/30); //The size of the paddle
final float CONTRACTED_PADDLE_WIDTH = SCREEN_SIZE/7; //Contracted width of the paddle
final float EXTENDED_PADDLE_WIDTH = SCREEN_SIZE/4; //Extended width of the paddle
int extendedPaddleTimer = 0, PADDLE_EXTEND_TIME = 1000; //The timer for the extended paddle, as well as the maximum time that it will remain extended
//Variables pertaining to balls
ArrayList <Ball> numBalls; //Sets arraylist for the balls
final int BALL_SIZE = SCREEN_SIZE/55; //The size of the balls
final int DEFAULT_BALL_SPEED = SCREEN_SIZE/100; //The default ball speed
final int HORIZANTAL_SPEED_SENSITIVITY = 8; //The sensitivity of the change of rate of speed for balls when hitting the paddle
final int MINIMUM_TIME_BEFORE_NEXT_HIT = 1; //The minimum time before the next ball can be hit - this is to stop a glitch that allows the ball to hit two bricks at once
boolean stickBallToPaddle = true; //If this is true, then the ball will stick to the paddle
//Variables pertaining to the bricks
ArrayList <Brick> numBricks; //Sets the arraylist for the bricks
PVector BRICK_SIZE = new PVector(SCREEN_SIZE*9/100, SCREEN_SIZE*3/100); //Size of the bricks
PVector brickColorScheme; //The color scheme of the bricks of the level - changes with each new spawn
final int COLOR_SCHEME_RANGE = 20; //The range of colors in the same color scheme - the larger it is, the more colorful
final int MINIMUM_COLOR_SCHEME_BRIGHTNESS = 30; //The minimum brightness of the color schemes
//Variables pertaining to the HUD and basic functioning of the game
PFont HUDfont; //The font for the HUD
int ballsLeft = 3; //The number of balls left - is equal to how many lives the player starts with
int currentLevel = 1; //The current level - is equal to what level the user starts with
int AVAILIBLE_LEVELS = 4; //The number of levels in the game - used to give the 'You Win!' message
boolean displayedIntroduction = false; //If the introductory message has been shown to the user yet or not
boolean displayWinningMessage = false; //If the winning message should be displayed
boolean pauseState = false; //If the game is paused or not
boolean gameOverState = false; //If the game has been lost or not
final int COLOR_CHANGE_FREQUENCY = 30; //The frequency of the color change for the color changing animations
int colorChangeTimer = COLOR_CHANGE_FREQUENCY; //The timer that determines when the color changing animation should change colors
color colorChangeAnimationColor; //The current color of the color change animation
//Variables pertaining to the powerups
ArrayList <PowerUp> numPowerUps = new ArrayList(); //Sets an arraylist for the powerups
final int CHANCE_OF_POWER_UP = 8; //The reciprical of the chance of a powerup dropping when a block is destroyed -e.g., 1 is a 100% chance, where as 2 is a 50% chance
final int TYPES_OF_POWER_UPS = 2; //The different types of powerups
final int POWER_UP_SIZE = SCREEN_SIZE/30; //The radius of all the power ups
final int POWER_UP_SPEED = SCREEN_SIZE/300; //The speed of the power up
int currentAmountOfBalls; //The current amount of balls on the screen - used to check for each ball on the game whilst disregarding the newly spawned ones, as to save memory
void setup() { //Runs once upon execution of the program
size(SCREEN_SIZE, SCREEN_SIZE, JAVA2D); //Creates a screen
HUDfont = loadFont("MicrosoftYaHei-48.vlw"); //Loads the font file from the data folde
playerPaddle = new Paddle(); //Sets the player's paddle
numBalls = new ArrayList(); //Sets the numBalls arraylist
numBricks = new ArrayList(); //Sets the numBricks arraylist
spawnLevel(currentLevel); //Spawns the first level
numBalls.add(new Ball(playerPaddle.paddleLocation.x + paddleSize.x/2, playerPaddle.paddleLocation.y - BALL_SIZE/2, 0, DEFAULT_BALL_SPEED)); //Spawns the first ball
}
void draw() { //Runs in a loop after the setup method
background(0); //Sets a black background
//Rendering of objects
for (int i = 0; i < numBalls.size(); i++) numBalls.get(i).renderBall(i); //Renders all balls
for (int i = 0; i < numBricks.size(); i++) numBricks.get(i).renderBrick(); //Renders all bricks
for (int i = 0; i < numPowerUps.size(); i++) numPowerUps.get(i).renderPowerUp(i); //Renders all power ups
playerPaddle.renderPaddle(); //Renders the player's paddle
renderHUD(); //Renders the player's HUD
//Checks and acts on the amount of balls
if (numBalls.size() == 0) { //If there are no balls left
if (!displayWinningMessage) ballsLeft--; //Decrease the amount of balls left by one if the user has not already won
stickBallToPaddle = true; //Stick the next spawned ball to the paddle
numPowerUps.clear(); //Removes all power-ups in motion
extendedPaddleTimer = 0; //Contracts the paddle
numBalls.add(new Ball(playerPaddle.paddleLocation.x + paddleSize.x/2, playerPaddle.paddleLocation.y - BALL_SIZE/2, 0, DEFAULT_BALL_SPEED)); //Adds a ball
}
if (ballsLeft <= 0) gameOverState = true; //If there are no lives left, show the game over screen
//Checks and acts on the amount of bricks
if (numBricks.size() == 0 && currentLevel <= AVAILIBLE_LEVELS) { //If there are no bricks left and the user has not completed all levels
numPowerUps.clear(); //Removes all power-ups in motion
numBalls.clear(); //Removes all balls
extendedPaddleTimer = 0; //Contracts the paddle
numBalls.add(new Ball(playerPaddle.paddleLocation.x + paddleSize.x/2, playerPaddle.paddleLocation.y - BALL_SIZE/2, 0, DEFAULT_BALL_SPEED)); //Adds a ball
stickBallToPaddle = true; //Sticks the ball back to the paddle
currentLevel++; //Increment current level by one
spawnLevel(currentLevel); //Spawns the next level
}
}
void mousePressed() { //If the mouse is pressed
stickBallToPaddle = false; //Un-stick the ball from the paddle
displayedIntroduction = true; //Remove the introduction message
}
void keyReleased() { //If a key is released
if (key == 'Q' || key == 'q') exit(); //If the player presses 'q', quit the game
if (key == 'P' || key == 'p') pauseState = !pauseState; //If the player presses 'p', toggle the pause
}
void renderHUD() { //Renders the player's HUD
noCursor(); //Removes the user's cursor
fill(colorChangeAnimationColor); //Colors white
textAlign(LEFT); //Aligns the text to the left of co-ordinates
textFont(HUDfont, SCREEN_SIZE*4/125); //Sets the text font
text("Balls Left: ", SCREEN_SIZE/100, SCREEN_SIZE/25); //Writes the text "Balls Left"
text("Current Level: " + currentLevel, SCREEN_SIZE/100, SCREEN_SIZE*7/80); //Writes out the current level
for (int ballsToDraw = 0; ballsToDraw < ballsLeft; ballsToDraw++) ellipse(SCREEN_SIZE*2/11 + ballsToDraw * BALL_SIZE*3/2, SCREEN_SIZE/32, BALL_SIZE, BALL_SIZE); //Draws a ball for each life left
textAlign(CENTER); //Aligns the text to the, center of co-ordinates
textFont(HUDfont, SCREEN_SIZE/50); //Sets the text font
if (!displayedIntroduction) text("Welcome to Rainbow Breaker!" + "\nTo let go of the ball, click the mouse." + "\nTo control the paddle, move the mouse." + "\nTo pause the game, press 'P'." + "\nTo quit the game, press 'Q'.", SCREEN_SIZE/2, SCREEN_SIZE*6/10); //Displays the introduction message
if (displayWinningMessage) text("Congratulations!" + "\nYou won Rainbow Breaker!" + "\nPress 'Q' to quit the game.", SCREEN_SIZE/2, SCREEN_SIZE/2); //If the user has won, display the winning text
if (pauseState) { //If the game is paused
cursor(ARROW); //Sets the user's cursor to an arrow
fill(0, 0, 0, 220); //Fills with a transparent black
rect(0, 0, SCREEN_SIZE, SCREEN_SIZE); //Darkens the whole screen
fill(255); //Colors white
textFont(HUDfont, SCREEN_SIZE*4/125); //Sets the text font
text("Game Paused", SCREEN_SIZE/2, SCREEN_SIZE/2); //Writes a pause message to the user
textFont(HUDfont, SCREEN_SIZE/50); //Sets the text font
text("Press 'P' to resume the game.", SCREEN_SIZE/2, SCREEN_SIZE*11/21); //Writes instructions regarding the pause to the user
}
else { //If the game is not paused
//The color-changing animation
if (colorChangeTimer >= COLOR_CHANGE_FREQUENCY) { //If it is time for the color change to occur
colorChangeTimer = 0; //Resets the color change timer
colorChangeAnimationColor = color(random(255), random(255), random(255)); //Randomizes the color of the imation
}
colorChangeTimer++; //Increments the color change timer
}
if (gameOverState) { //If the game has been lost
background(0); //Colors the screen black, overlaying all the renderings
fill(colorChangeAnimationColor); //Fills with the color change animation color
textFont(HUDfont, SCREEN_SIZE*4/125); //Sets the text font
text("Game Over", SCREEN_SIZE/2, SCREEN_SIZE/2); //Writes a game over message to the user
textFont(HUDfont, SCREEN_SIZE/50); //Sets the text font
text("Press 'Q' to exit the game.", SCREEN_SIZE/2, SCREEN_SIZE*11/21); //Writes instructions regarding the quit to the user
}
}
void spawnLevel(int levelToSpawn) { //Spawns the level that should be spawned
do {
brickColorScheme = new PVector(random(255), random(255), random(255)); //Randomizes the color of the brick scheme
}
while (brickColorScheme.x + brickColorScheme.y + brickColorScheme.z < MINIMUM_COLOR_SCHEME_BRIGHTNESS); //If the color is less then the neccessary brightness, re-do the randomization
switch(levelToSpawn) { //Checks the current level that was already incremented before this was called
case 1: //If must spawn level one
for (float spawnYofBrick = SCREEN_SIZE*10/45; spawnYofBrick < SCREEN_SIZE - BRICK_SIZE.y*20; spawnYofBrick += BRICK_SIZE.y) //Arranges each row one block apart
for (float spawnXofBrick = BRICK_SIZE.x; spawnXofBrick < SCREEN_SIZE - BRICK_SIZE.x*2; spawnXofBrick += BRICK_SIZE.x) //Aranges each column one block apart
numBricks.add(new Brick(spawnXofBrick, spawnYofBrick, brickColorScheme)); //Spawns each brick
break;
case 2: //If must spawn level two
for (float spawnYofBrick = SCREEN_SIZE*8/45; spawnYofBrick < SCREEN_SIZE - BRICK_SIZE.y*15; spawnYofBrick += BRICK_SIZE.y) //Arranges each row one block apart
for (float spawnXofBrick = BRICK_SIZE.x; spawnXofBrick < SCREEN_SIZE - BRICK_SIZE.x*2; spawnXofBrick += BRICK_SIZE.x*2)
numBricks.add(new Brick(spawnXofBrick, spawnYofBrick, brickColorScheme)); //Spawns each brick
break;
case 3: //If must spawn level three
for (float spawnYofBrick = SCREEN_SIZE*14/45; spawnYofBrick < SCREEN_SIZE - BRICK_SIZE.y*15; spawnYofBrick += BRICK_SIZE.y) //Arranges each row one block apart
for (float spawnXofBrick = BRICK_SIZE.x; spawnXofBrick < SCREEN_SIZE - BRICK_SIZE.x*2; spawnXofBrick += BRICK_SIZE.x) //Aranges each column one block apart
if (spawnXofBrick < SCREEN_SIZE*3/8 || spawnXofBrick > SCREEN_SIZE/2) numBricks.add(new Brick(spawnXofBrick, spawnYofBrick, brickColorScheme)); //Spawns each brick, except in the middle column
break;
case 4: //If must spawn level four
for (float spawnYofBrick = SCREEN_SIZE*2/9; spawnYofBrick < SCREEN_SIZE - BRICK_SIZE.y*17; spawnYofBrick += BRICK_SIZE.y) //Arranges each row one block apart
for (float spawnXofBrick = BRICK_SIZE.x; spawnXofBrick < SCREEN_SIZE - BRICK_SIZE.x*2; spawnXofBrick += BRICK_SIZE.x) //Aranges each column one block apart
if(spawnXofBrick == BRICK_SIZE.x || spawnXofBrick >= SCREEN_SIZE - BRICK_SIZE.x*3 //If it is in one of the two columns
|| spawnYofBrick == SCREEN_SIZE*2/9 || spawnYofBrick >= SCREEN_SIZE - BRICK_SIZE.y*18) //If it is in on of the two rows
numBricks.add(new Brick(spawnXofBrick, spawnYofBrick, brickColorScheme)); //Spawns bricks in a box shape
break;
case 5: //If must spawn level five (which is non-existent)
displayWinningMessage = true; //Display the winning message, as there are no more levels
break;
}
}
A simple re-make of Brick Breaker, except more colourful.
Version 2.00 -
- Literally re-made the game
- Cut out almost half the code through more efficient algorithms
- Removed some features that were either unnecessary, like the main menu, or made the game too easy, like the extra life power up
- Infinite colour scheme variations
- One extra level added
- Aesthetically upgraded the HUD
Version 1.02 -
- Paddle changes colour to that of the most recent ball hit
Version 1.01 -
- Fixed the screen size
- Fixed a bug in level transitions
- Added two levels
- Added a randomized colour scheme