Brickles

This game is very similar to Breakout, one of the first commercial video games and a popular game played on Apple II computers. This example has its origins in a course we developed to teach object-oriented design concepts and C++ program­ming. Our goal was to find an application whose design was simple enough to understand and complete in a week of training while at the same time be both conducive to enhancements and interesting to programmers whose backgrounds range over a variety of application domains and environments.

Basic Brickles Components

Brickles is an arcade game whose starting configuration is shown in Figure 1. The play field is rectangular, bounded by two walls, a ceiling, and a floor. The play field contains an array of bricks, referred to as the “brick pile.” A player’s objec­tive is to break all the bricks in the brick pile by hitting each brick with a puck that can be struck by a paddle under player control. When the puck hits a brick, the brick breaks. A puck bounces off walls, the ceiling, bricks (as they break), and the paddle. At the start of play, a player is given three pucks with which to destroy the bricks. A player wins a game when all bricks have been broken. A player loses if the supply of pucks is exhausted before all of the bricks are broken.


 

 

Figure 1 The Brickles Startup Configuration

When play starts, a puck placed in the center of the play field begins to move in a downward direction. The paddle is controlled by the player via a mouse attached to the computer. The player must move the paddle so that the puck hits the paddle and not the floor. When the puck hits the paddle, it bounces upward. Whenever the puck hits a brick, the brick is destroyed. If the puck misses the paddle and hits the floor, it is removed from play and one of the remaining pucks is put into play. If all pucks are lost to the floor, play ends and the player loses.

Brickles Physics

As the puck moves through the play field, it encounters various components of the play field. The interactions between them are as follows [see also Figure 2, Figure 3, and Figure 4].

Ceiling and walls

The puck bounces off the ceiling and walls in accordance with the laws of physics, neglecting friction and gravity—that is, angle of reflection equals angle of incidence.

 

 

Figure 2 Interactions between Puck and Boundaries

Floor

The floor absorbs pucks. A puck that hits the floor does not rebound, but is removed from play.

Bricks

The puck bounces off a brick such that the angle of reflection equals the angle of incidence. Upon being struck, a brick is destroyed. Note that bricks can be hit by a puck from above as well as from below. They also have sufficient thickness that they can be hit from the side. For the sake of simplicity, it is acceptable to assume that bricks are treated as though they have no thickness. Thus, it is only the vertical component of the puck’s direction that is changed when the puck hits the brick.

 

Figure 3 Puck interactions with bricks.

Paddle

The player uses a paddle to control the direction of the puck. The puck bounces off the paddle based on the direction of the puck as it hits the paddle and on which part of the paddle is hit. Divide the paddle into thirds and define the near third as being the left third of the paddle if the puck is coming in from the left and the right third if the puck is coming in from the right. Define the far third similarly, and the middle third as the remaining third. The rules of reflection are as follows:


·         If the puck hits the paddle on its near third then the puck returns in the exact opposite direction from which it came.

·         If the puck hits the paddle on the middle third then the angle of reflection is a little steeper than the angle of inci­dence. The puck’s movement is constrained such that it must never be completely vertical.

·         If the puck hits the paddle on the far third then the angle of reflection is a little shallower than the angle of inci­dence. The puck’s movement is constrained such that it must never be completely horizontal.

 

 

Figure 4 Puck interactions with the paddle.

Puck

The player is given a fixed number of pucks at the beginning of the game, but only one is in play at any given time. Once one puck hits the floor, the next is brought into play, assuming another is available. The puck has a current direction and speed and moves according to an automatic timer. As seen above, collisions may change the direction of the puck, but not the speed.

Game Environment

The first implementation of Brickles is to run as an application within a Microsoft Windows® environment and behaves as follows:

·         The game shall start when there is a left mouse button click.

·         A player can “exit” the game at any time before it is won or lost.

·         A player can “pause” the game at any time until play ends.

·         A player can “resume” a paused game.

·         A congratulatory message shall be displayed in the case of a player winning the game. Similarly, a consolation mes­sage shall be displayed in the case of a player losing the game.