CPSC170A Assignment 1
Break Out

Due Feburary 1st, 2013

For this assignment you will modify your pong program from lab 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

The paddle should be on the bottom of the screen and only able to move laterally. There should be enough bricks to arrange them in a pattern at the top of the window. After the ball bounces off a brick, the brick should disappear. That is it should no longer be drawn and should no longer be checked for intersection with the ball. When all of the bricks have disappeared the program should display a congratulatory message.

You are required to have two different types of bricks. One brick is a standard brick as described above; They break and disappear after being struck once. Another type of brick you are required to have are strong bricks, which take multiple hits to break.

Note that the collision detection method covered in lab does not specify how to determine which side of a brick the ball collides with. A simple solution to this problem is to make the bricks wide but not very tall and to assume that all collisions are with either the top or bottom of the brick. Also note that that the collision detection method from lab can not determine which brick is hit first, if the ball is intersecting with multiple bricks. This can be a problem because if the ball does intersect with two bricks the result will be to change the velocity twice, and the ball will not bounce. A simple solution to this problem is to arrange the bricks so that it is not possible for the ball to intersect with multiple bricks simultaneously.

Submission: Submit your code, with your modified test cases, as a zip file with your name as the zip file name (FIRSTNAMELASTNAME.zip)on the course Inquire site by
5:00 PM February 1st, 2013.

Test Cases

This is a fairly complicated project, and on the surface seems that it would be difficult to test if it is working correctly. However, breaking the code into the different classes makes testing a little bit easier. Instead of testing through the interactive portion, you can create other test files which can explicitly state your test cases.

For example, in my test_pong.py, you can see that I create a window (which is just the updating window from lab), and a ball. I specify explicitly the x and y coordinates of the ball, as well as the x and y velocities. This code tests to make sure the ball bounces off the top wall.

Your should come up with a at least 3 test cases that could be used to verify to yourself that your code meets the requirements of this assignment. Each test case should be written in a file called test_pong_#.py, replacing the "#" with a unique identifier for each test case. Also include another, plain-text document that describes the purpose of each test case, and what behavior you expect to observe.

Submission: Submit your test_pong_#.py files, as well as another plain-text file with descriptions of the expected behavior of the test_pong_#.py programs, as a zip file (FIRSTNAMELASTNAME.zip) on the course inqiure website by 10:00 PM January 28th, 2013.

Extra

Mouse Control: Controlling the paddle with the keyboard does not always provide the greatest precision when playing a game of Break Out. Change the controls so the paddle gets its x position based on the x position of the mouse.

Spin: The game can be made more fun by giving the user more control over how the ball bounces off of the paddle. In order to do this you will need to modify the ball's direction without modifying its speed. This is difficult when both the speed and direction are specified with velocity. Change the ball's instance data to be direction (the angle in radians from the x-axis the ball is traveling) and speed (the number of pixels per frame of animation). When the ball hits the paddle use the velocity of the paddle to modify the angle that the ball bounces. The faster the paddle is moving the more the ball's angle should change.

Levels: After the player destroys all of the bricks on the screen, resart the game with a new, more difficult arrangement of bricks.

High Score: Keep track track of how well the player does by awarding points based on the number of bricks destroyed and how quickly. Keep a list of the highest scores in a file and display them when the player's game is over.

Bonuses: Add bricks that when hit modify the game play to make it easier for the player. Some examples are, slowing down the ball, growing the paddle, growing the ball, or adding an extra ball. To make it more fun the bonuses can fall from the destroyed brick and only be awarded if they intersect with the paddle.