Assignment 2: “Breakout, The Powerup Update”
Objectives
- Read and understand all of the Breakout source code from Lecture 1.
- 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 when the player collects a second new powerup, a key, which should only spawn when such aBrickexists and randomly as per theBallpowerup.
Getting Started
GitHub Classroom
In this course, we’ll use GitHub Classroom to distribute projects and collect submissions. To begin Assignment 1:
- Click here to go to the GitHub Classroom page for starting the assignment.
- Click the green “Accept this assignment” button. This will create a GitHub repository for your project. Recall that a git repository is just a location where your code will be stored and which can be used to keep track of changes you make to your code over time.
- Click on the link that follows “Your assignment has been created here”, which will direct you to the GitHub repository page for your project. It may take a few seconds for GitHub to finish creating your repository.
- In the upper-right corner of the repository page, click the “Fork” button, and then (if prompted) click on your username. This will create a fork of your project repository, a version of the repository that belongs to your GitHub account.
- Now, you should be looking at a GitHub repository titled username/assignment2-username, where username is your GitHub username. This will be the repository to which you will push all of your code while working on your assignment. When working on the assignment, do not directly push to the games50/assignment2-username repository: always push your code to your username/assignment2-username repository.
Setup
Time to pull down the starting code for Breakout! First, on your main repository page (https://github.com/username/assignment2-username), click on the green “Clone or download” button. Copy the “Clone with HTTPS” link to your clipboard (if familiar with SSH, you can use that instead).
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 want to store your
project on your computer (recall that the cd command can change your current
directory), and run
git clone repository_url assignment2
where repository_url is the link you just copied from GitHub. You will be
prompted for your GitHub username and password
Go ahead and run cd assignment2 to enter your repository.
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!
Your goals this assignment:
- 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!
How to Submit
Step 1 of 1
- Go to the GitHub page for your username/assignment2-username repository (note: this is different from the games50/assignment2-username repository).
- On the right side of the screen, click the Pull request button.
- Make sure that the “base fork” is
games50/assignment2-username, and the “head fork” isusername/assignment2-username. - Click “Create pull request”.
- On the next page, click the “Create pull request” button again.
Congratulations! You’ve completed Assignment 2.