Breakout is a simple 2D video game, originally published by Atari in 1976. It is written entirely in C++. The graphical component of the game is implemented using the X11 library. In the game, a layer of bricks lines the top third of the screen. A ball travels across the screen, bouncing off the top and side walls of the screen. When a brick is hit, the ball bounces away and the brick is destroyed. The player loses a turn when the ball touches the bottom of the screen. To prevent this from happening, the player has a movable paddle to bounce the ball upward, keeping it in play.
make
make clean
./breakout
Note: The compilation and execution step can be combined into a single step by running: make run.
- -frame-rate n is measured in frames per second and controls how often the screen is painted or redrawn. The default frame rate is 30 frames per second.
- -speed n is measured in pixels per second and controls how fast the ball moves. The default speed is 3.5 pixels per second.
The game can be played using a mouse or a keyboard. At any point in the game, you can switch between the two.
- move left to move the paddle left
- move right to move the paddle right
- click to release the ball from the paddle
- A to move the paddle left
- D to move the paddle right
- Space Bar to release the ball from the paddle
- Escape to quit the game
There are two other special types of bricks in addition to the normal bricks (represented by a rectangle with a solid colour fill). The first type of special brick is "elongate" brick (represented by an outline of a rectangle with a smaller black rectangle in it), which makes the paddle twice as long when They are hit by the ball. The second type of special brick is "shorten" brick (represented by a rectangle with a strip of white in the centre of it), which make the ball speed slower by 0.2 pixels per second. However, the "elongate" brick will not make the paddle longer than a third of the screen width. Similarly, the "shorten" brick will not slow the ball slower than 3 pixels per second. There is a 1/50 chance that a "elongate" brick or a "shorten" brick is on the screen.
- X11 library has memory leaks.
Breakout is licensed under the MIT license.