Breakout
Objectives
- Add a powerup to the game that spawns two extra
Balls. - Grow and shrink the paddle when the player gains enough points or loses a life.
- Add a locked
Brickthat will only open with a key.
Getting Started
Download the distribution code for your game from cdn.cs50.net/2d/2025/x/projects/2/breakout.zip and unzip breakout.zip, which should yield a directory called breakout.
Then, in a terminal window, move to the directory where you extracted breakout, and run
cd breakout
Break(out) a Leg!
By now, we’ve gotten our feet wet with states, randomization, and much more; this time, we’ll be diving in a little bit more and adding some new features entirely!
Specification
-
Add a
Powerupclass to the game that spawns a powerup (images located at the bottom of the sprite sheet in the distribution code). ThisPowerupshould spawn randomly, be it on a timer or when the ball hits aBlockenough times, and gradually descend toward the player. Once collided with thePaddle, two moreBalls should spawn and behave identically to the original, including all collision and scoring points for the player. Once the player wins and proceeds to theVictoryStatefor their current level, theBalls should reset so that there is only one active again. -
Grow and shrink the
Paddlesuch that it’s no longer just one fixed size forever. In particular, thePaddleshould shrink if the player loses a heart (but no smaller of course than the smallest paddle size) and should grow if the player exceeds a certain amount of score (but no larger than the largestPaddle). This may not make the game completely balanced once thePaddleis sufficiently large, but it will be a great way to get comfortable interacting withQuads and all of the tables we have allocated for them inmain.lua! -
Add a locked
Brick(located in the sprite sheet) to the level spawning, as well as a key powerup (also in the sprite sheet). The lockedBrickshould not be breakable by the ball normally, unless they of course have the keyPowerup! The keyPowerupshould spawn randomly just like theBallPowerupand descend toward the bottom of the screen just the same, where thePaddlehas the chance to collide with it and pick it up. You’ll need to take a closer look at theLevelMakerclass to see how we could implement the lockedBrickinto the level generation. Not every level needs to have lockedBricks; just include them occasionally! Perhaps make them worth a lot more points as well in order to compel their design. Note that this feature will require changes to several parts of the code, including even splitting up the sprite sheet intoBricks!
Be sure to comment your code in the places where you implement the above items. This is true for all implementations, but particularly if you do so in a spot we might not expect you to.
Errata
NONE
How to Submit
When you submit your project, the contents of your branch must match the file structure of the unzipped distribution code exactly as originally received. That is to say, your files should not be nested inside of any other directories of your own creation or otherwise deviate from the file structure we gave you. Your branch should also not contain any code from any other projects, only this one. Failure to adhere to this file structure will result in your submission being rejected.
By way of a simple example, for this project that means that if the grading staff visits https://github.com/me50/USERNAME/blob/games50/projects/2025/x/breakout/src/Paddle.lua (where USERNAME is your own GitHub username as provided in the form, below) we should be brought to your Paddle.lua file for Breakout. If that’s not how your code is organized when you check (e.g., you get a 404 error or don’t see your edits), reorganize your repository as needed to match this paradigm. Code improperly organized will not be eligible for a passing score.
- If you haven’t already, visit this link, log in with your GitHub account, and click Authorize cs50. Then, check the box indicating that you’d like to grant course staff access to your submissions, and click Join course.
-
Install Git and, optionally, install
submit50. -
Using Git, push your work to
https://github.com/me50/USERNAME.git, whereUSERNAMEis your GitHub username, on a branch calledgames50/projects/2025/x/breakoutor, if you’ve installedsubmit50, executesubmit50 games50/projects/2025/x/breakoutinstead.
-
Record a screencast, not to exceed 5 minutes in length in which you demonstrate your game’s functionality. Upload that video to YouTube (as unlisted or public, but not private). This video’s requirements are:
- It is not a YouTube “short”.
- The video begins with a slide or text overlay containing both your edX and GitHub usernames.
- It must show your game live and in action. Do not use this video to walk us through any code.
- It demonstrates that all three (3) items of the specification have been implemented.
- The video description has been timestamped at the (first) point where your video demonstrates each of the above-referenced implementations.
- The video has been uploaded less than one month from the time of your submission of the form for this project (the final step below).
- Submit this form.
You can then go to https://cs50.me/cs502d to view your current progress!