CPSC 170 Post Lab 1
Break Out
Due Before Class on Tuesday, January 25th

bricks

For this assignment you will 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 disappear. The player wins the game by making all of the bricks disappear.

Details

You can use the Pong.tar.gz code that we created in class as a starting point. Be sure to change the class name because the program will no longer be pong, it will be Break Out. Begin by adding to the panel class an instance variable that is an array of Sprites that represents all of the bricks. In the constructor initialize the array and all of the Sprites in it. Add to the paintComponent method a loop that iterates over the entire array of sprites and for each sprite, draws it. Next, add a loop to the actionPerformed method that uses the overlap methods of the sprite class to test if the ball intersects with any of the bricks and on which side. If the ball does, then it should change the direction based on the side that it hit. Next add an instance variable to the sprite class that specifies if a sprite is visible. Modify the paint component loop to only draw if a sprite is visible, and the action performed to only perform collision detection if the sprite is visible. Finally, add to the if statement that tests if the ball hits a brick code to set the brick that was hit to not be visible.

Submission: Tar and submit your code on the course Inquire site.