{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

21-Assignment-4-Breakout

# 21-Assignment-4-Breakout - CS106A Handout 21 April 25th...

This preview shows pages 1–3. Sign up to view the full content.

CS106A Handout 21 Spring 2011 April 25 th , 2011 Assignment 4: Breakout Assignment written by Eric Roberts. Your job in this assignment is to write the classic arcade game of Breakout, which was invented by Steve Wozniak before he founded Apple with Steve Jobs. It is a large assignment, but well within your capabilities, as long as you break the problem up into manageable pieces. The decomposition is discussed in this handout, and there are several suggestions for staying on top of things in the “Strategy and tactics” section later in this handout. We’ll be leading YEAH hours tomorrow (Tuesday, April 26 th ) evening in Hewlett 201 from 7:00 until 8:30 p.m. to outline how you should approach the assignment. Due Wednesday, May 4 th at 5:00 p.m. The Breakout game In Breakout, the initial configuration of the world appears as shown on the right. The colored rectangles in the top part of the screen are bricks, and the slightly larger rectangle at the bottom is the paddle. The paddle is in a fixed position in the vertical dimension, but moves back and forth across the screen along with the mouse until it reaches the edge of its space. A complete game consists of three turns. On each turn, a ball is launched from the center of the window toward the bottom of the screen at a random angle. That ball bounces off the paddle and the walls of the world, in accordance with the physical principle generally expressed as "the angle of incidence equals the angle of reflection" (which turns out to be very easy to implement as discussed later in this handout). Thus, after two bounces—one off the paddle and one off the right wall—the ball might have the trajectory shown in the second diagram. (Note that the dotted line is there only to show the ball’s path and won’t appear on the screen.) As you can see from the second diagram, the ball is about to collide with one of the bricks on the bottom row. When that happens, the ball bounces just as it does on any other collision, but the brick disappears. The third diagram shows what the game looks like after

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
that collision and after the player has moved the paddle to put it in line with the oncoming ball. The play on a turn continues in this way until one of two conditions occurs: 1. The ball hits the lower wall, which means that the player must have missed it with the paddle. In this case, the turn ends and, provided the player has one or two turns left, the next ball is served. If not, the game ends in a loss for the player. 2. The last brick is eliminated. In this case, the player wins, and the game ends immediately. After all the bricks in a particular column have been cleared, a path will open to the top wall. When this delightful situation occurs, the ball will often bounce back and forth several times between the top wall and the upper line of bricks without the user ever having to worry about hitting the ball with the paddle. This condition is a reward for "breaking out" and gives meaning to the name of the game. The diagram on the right shows the situation
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 9

21-Assignment-4-Breakout - CS106A Handout 21 April 25th...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online