Breakout – more details
(NOTE: for co-ordinates in Greenfoot the position (x=0, y=0) is the top left corner)
· The game has a grid of bricks 11 wide and 8 deep. The colour of the rows of
bricks varies – two rows each of yellow, green, blue and red (from front to back).
The value of the bricks is also different for each row: see
BreakoutWorld.POINTS, which gives the points value for each row (from the
back to the front).
· The ball starts in the position given by
· The ball initially moves at 45 degrees, towards the top right corner. Each time the
ball hits something it will bounce through 90 degrees. This is achieved by simply
reversing the appropriate (x or y) direction. For example, the initial direction will
be x = +1, y = h–1. On striking the right hand wall the direction will change to x =
–1, y = –1 (i.e. x direction swaps from +1 to –1).
· When the ball hits a brick, the brick disappears and its point value is added to the
· When the ball misses the bat and drops off the screen the player loses one of their
3 “lives” and, if the player still has 1 or more lives, the ball returns to its initial
position and play continues
· The bat must get its instructions from the Controller class. This has a mode
variable that can be set to “EXPERT” or any other value. If this variable is set to
“EXPERT”, the controller passes back the required instructions (“left” or “right”)
to ensure the bat always hits the ball. For any other value it simply returns either
“left” (left arrow), “right” (right arrow) or “” (nothing) depending on what key is
currently pressed. You must include logic to prevent the bat leaving the screen.
· Play ends when there are no bricks left (a win) or no more lives (a loss).
here is the zip file.
should look like the image.