Breakout
Objectives
- Read and understand all of the Breakout source code from Lecture 2.
- Add a powerup to the game that spawns two extra
Ball
s. - Grow and shrink the Paddle when the player gains enough points or loses a life.
- Add a locked
Brick
that will only open when the player collects a second new powerup, a key, which should only spawn when such aBrick
exists and randomly as per theBall
powerup.
Demo
by Edward Kang
Getting Started
Download the distro code for your game from cdn.cs50.net/games/2018/x/projects/2/breakout.zip and unzip breakout.zip
, which should yield a directory called breakout
.
Then, in a terminal window (located in /Applications/Utilities
on Mac or by typing cmd
in the Windows task bar), move to the directory where you extracted breakout
(recall that the cd
command can change your current directory), and run
cd breakout
Break(out) a Leg!
Welcome to your third assignment! 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
Powerup
class to the game that spawns a powerup (images located at the bottom of the sprite sheet in the distribution code). ThisPowerup
should spawn randomly, be it on a timer or when the Ball hits aBlock
enough times, and gradually descend toward the player. Once collided with thePaddle
, two moreBall
s should spawn and behave identically to the original, including all collision and scoring points for the player. Once the player wins and proceeds to theVictoryState
for their current level, theBall
s should reset so that there is only one active again. - Grow and shrink the
Paddle
such that it’s no longer just one fixed size forever. In particular, thePaddle
should 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 thePaddle
is sufficiently large, but it will be a great way to get comfortable interacting withQuad
s 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 lockedBrick
should not be breakable by the ball normally, unless they of course have the keyPowerup
! The keyPowerup
should spawn randomly just like theBall
Powerup
and descend toward the bottom of the screen just the same, where thePaddle
has the chance to collide with it and pick it up. You’ll need to take a closer look at theLevelMaker
class to see how we could implement the lockedBrick
into the level generation. Not every level needs to have lockedBrick
s; 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 intoBrick
s!
Errata
ParticleSystem:setAreaSpread
has been renamed toParticleSystem:setEmissionArea
in LÖVE 11.0.love.filesystem.exists
has been renamed tolove.filesystem.getInfo
in LÖVE 11.0.love.audio.newSource
now must take a second argument ('static'
or'stream'
), whereas previously it was optional.
How to Submit
When you submit your project, the contents of your games50/projects/2018/x/breakout
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 likely 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/2018/x/breakout/src/Paddle.lua
(where USERNAME
is your own GitHub username as provided in the form, below) we should be brought to the 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.
- If you haven’t done so 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.
The change to /projects/2018
below is intentional, as CS50 courses have changed to a scheme that reflects when the project was initially released. So the 2018 here is correct, even though it’s no longer 2018!
-
Using Git, push your work to
https://github.com/me50/USERNAME.git
, whereUSERNAME
is your GitHub username, on a branch calledgames50/projects/2018/x/breakout
or, if you’ve installedsubmit50
, executesubmit50 games50/projects/2018/x/breakout
instead.
- Record a screencast, not to exceed 5 minutes in length (and not uploaded more than one month prior to your submission of this project) in which you demonstrate your app’s functionality. Upload that video to YouTube (as unlisted or public, but not private) or somewhere else.
- To aid in the staff’s review, in your video’s description on YouTube (not in your form submission), you should timestamp where each of the following occurs in your gameplay demonstration. This is not optional; failure to do this will result in your submission being rejected:
- Multiball powerup
- Paddle growth
- Key powerup obtained
- Key block unlocked
- Submit this form.
You can then go to https://cs50.me/cs50g to view your current progress!