CPSC 170 Post Lab 2
Break Out
Due Before Class on Tuesday, January 23rd

For this assignment you modify your pong program from lab one to make the game Break Out. For those that do not know the game, Break Out is a game similar to Pong that consists of a user controlled paddle and a ball bouncing around the screen. Break Out also includes bricks (rectangles) at the opposite side of the screen as the paddle. When the ball bounces off of the bricks they dissapear. The player wins the game by making all of the bricks dissappear. If you would prefer to base your program off of the pong program that we created in class you can copy the files Pong.java and PongPanel.java to your lab directory.

Details

Begin by creating a class that represents a brick. The class will need instance variables for the location and size of the brick. In addition to a constructor method that initializes the instance variables and getter and setter methods you should include a method that tests for the intersection of the brick and a ball. Think carefully about what parameters this method will need.

Next, add to the panel class an instance variable that is an array of Bricks and in the constructor initialize the array and all of the bricks in it. Add to the paintComponent method a loop that iterates over the entire array of bricks and for each brick, if it is visible, draws it. Finally, add a loop to the actionPerformed method that tests if the ball intersects with any of the bricks that are visible. If the ball does, then it should change the direction of the ball as if it hit the top of the window and set the brick that it hit to not be visible.

Lastly, add something else new to the program, whatever you think would make the program better. Include in your comments for the panel class a description of what you have added.


Hand In: Tar and email your code to your instructor with a subject of cpsc170 postlab2.