CS50x Week 4: Breakout (Problem set)

GUI (Graphical User interface) is interface that interacts with user through graphics as opposed to text user interface that interacts through text. For example, a game of tetris uses the GUI, while old game such as Discworld MUD uses text user interface. This week, we used an API (Application programming interface) provided by SPL (Stanford Portable Library) to make a GUI game.

The game is called Breakout.


In this game, the user can move the paddle left and right using their mouse. When the screen is clicked, the ball will start dropping, it will bounce when it hits the paddle, don’t let the ball fall to the bottom edge, or you will lose life. If it hits the brick, the ball will destroy the brick and bounce back towards the paddle and point is increased. The user has 3 lives and the game will finish when the user has 0 live left or when all the bricks are broken.

For detail guide on how to code this game, refer to CS50x problem set 4 standard version and hacker version. Also, you would like to refer to the documentation of SPL for gobjects.h, gevents.h, and gwindows.h.

Standard version: You will need to code a standard breakout game.

Breakout standard version by Ling Gen Sheng Shaun
Breakout standard version by Ling Gen Sheng Shaun

Hacker version: You will need to code a GOD mode, where the paddle will move according to the x position of the ball, essentially the computer is playing the game for you. Also, in the hacker version, extra requirements are set, such as paddle shrinking mechanism (paddle width will decrease when a brick is hit), variable scoring mechanism (bricks in the higher row will have higher points), variable-velocity mechanism (velocity of ball increases when you hit a brick), and laser (clicking during game will make the paddle shoot laser beam at the brick, however if the laser hits the ball, its game over).

Breakout hacker version by Ling Gen Sheng Shaun
Breakout hacker version by Ling Gen Sheng Shaun

My codes: https://github.com/shaunlgs/CS50x
Other posts in the series: Harvard CS50x 2014

Leave a Reply