Class BreakoutWorld

java.lang.Object
  extended by greenfoot.World
      extended by BreakoutWorld

public class BreakoutWorld
extends greenfoot.World

Holds a game of breakout. In breakout there are 10 rows of bricks that the user must get rid of to win. To get rid of bricks hit them with the ball. Use the paddle to hit the ball. Use the left and right arrow keys to move the paddle. The user has 3 balls to use to try to win the game and if the last ball gets past the paddle the user loses. This game is based on Breakout by Eric Roberts who presented it as a nifty assignment at SIGCSE in 2006 using the Java Task Force libraries.

Version:
1.0, April 6, 2007
Author:
Barbara Ericson, Georgia Tech

Field Summary
static int BRICK_HEIGHT
          the height of the bricks in pixels (cells)
static int BRICK_SEP
          the distance between bricks in pixels (cells)
static int BRICK_WIDTH
          the width of the bricks in pixels (cells)
static int BRICK_Y_OFFSET
          distance from the top edge in pixels (cells)
static java.awt.Color[] colorArray
          the colors to use for each row of bricks
static int HEIGHT
          world height in pixels (cells)
static int NUM_BRICKS_PER_ROW
          the number of bricks per row
static int NUM_ROWS
          number of rows of bricks
static int RESOLUTION
          the number of pixels per cell
static int WIDTH
          world width in pixels (cells)
 
Constructor Summary
BreakoutWorld()
          No argument constructor
 
Method Summary
 void checkIfWon()
          Method to check if the game is over and if so tell the user and stop the simulation
 int getNumBalls()
          Method to get the number of balls created
 void newBall()
          Method to add a new ball
 void setUpBreakout()
          Method to set up the breakout game
 void updateImage()
          Method to create and set the image for the background
 
Methods inherited from class greenfoot.World
addObject, getBackground, getCellSize, getColorAt, getHeight, getObjects, getObjectsAt, getWidth, isTiled, removeObject, removeObjects, repaint, setBackground, setBackground, setPaintOrder, setTiled
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BRICK_HEIGHT

public static final int BRICK_HEIGHT
the height of the bricks in pixels (cells)

See Also:
Constant Field Values

BRICK_SEP

public static final int BRICK_SEP
the distance between bricks in pixels (cells)

See Also:
Constant Field Values

BRICK_WIDTH

public static final int BRICK_WIDTH
the width of the bricks in pixels (cells)

See Also:
Constant Field Values

BRICK_Y_OFFSET

public static final int BRICK_Y_OFFSET
distance from the top edge in pixels (cells)

See Also:
Constant Field Values

colorArray

public static final java.awt.Color[] colorArray
the colors to use for each row of bricks


HEIGHT

public static final int HEIGHT
world height in pixels (cells)

See Also:
Constant Field Values

NUM_BRICKS_PER_ROW

public static final int NUM_BRICKS_PER_ROW
the number of bricks per row

See Also:
Constant Field Values

NUM_ROWS

public static final int NUM_ROWS
number of rows of bricks

See Also:
Constant Field Values

RESOLUTION

public static final int RESOLUTION
the number of pixels per cell

See Also:
Constant Field Values

WIDTH

public static final int WIDTH
world width in pixels (cells)

See Also:
Constant Field Values
Constructor Detail

BreakoutWorld

public BreakoutWorld()
No argument constructor

Method Detail

checkIfWon

public void checkIfWon()
Method to check if the game is over and if so tell the user and stop the simulation


getNumBalls

public int getNumBalls()
Method to get the number of balls created

Returns:
the number of balls created in the game

newBall

public void newBall()
Method to add a new ball


setUpBreakout

public void setUpBreakout()
Method to set up the breakout game


updateImage

public void updateImage()
Method to create and set the image for the background