java.lang.Objectgreenfoot.World
BreakoutWorld
public class BreakoutWorld
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.
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 |
---|
public static final int BRICK_HEIGHT
public static final int BRICK_SEP
public static final int BRICK_WIDTH
public static final int BRICK_Y_OFFSET
public static final java.awt.Color[] colorArray
public static final int HEIGHT
public static final int NUM_BRICKS_PER_ROW
public static final int NUM_ROWS
public static final int RESOLUTION
public static final int WIDTH
Constructor Detail |
---|
public BreakoutWorld()
Method Detail |
---|
public void checkIfWon()
public int getNumBalls()
public void newBall()
public void setUpBreakout()
public void updateImage()