Assignment 6: “Angry Birds, The Tri-Shot Update”
Objectives
- Read and understand all of the Angry Birds source code from Lecture 6.
- Implement it such that when the player presses the space bar after they’ve launched an
Alien(and it hasn’t hit anything yet), split theAlieninto threeAliensthat all behave just like the baseAlien.
Getting Started
GitHub Classroom
In this course, we’ll use GitHub Classroom to distribute projects and collect submissions. To begin Assignment 5:
- 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/assignment6-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/assignment6-username repository: always push your code to your username/assignment6-username repository.
Setup
Time to pull down the starting code for Angry Birds! First, on your main repository page (https://github.com/username/assignment6-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 assignment6
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 assignment6 to enter your repository.
Three’s Company
Welcome to your sixth assignment! This week, we took a look at the fundamentals of Box2D, one of the most widely-used 2D physics engines, and how it ties into LÖVE, with its built-in wrappers for it. This assignment will be a little simpler than some of the previous ones (indeed, there’s only one core objective, albeit a reasonably complex one) but will still require knowledge of Box2D and the distro before we can dive in too quickly.
Your goal this assignment:
- Implement it such that when the player presses the space bar after they’ve launched an
Alien(and it hasn’t hit anything yet), split theAlieninto threeAliensthat all behave just like the baseAlien. The code for actually launching theAlienexists inAlienLaunchMarker, and we could naively implement most, if not all, of this code in the same class, since theAlienin question we want to split off is a field of this class. However, because we want to only allow splitting before we’ve hit anything, we need a flag that will get triggered whenever thisAliencollides with anything else, so we’ll likely want the logic for this in theLevelitself here, since that is where we pass in the collision callbacks viaWorld:setCallbacks(). The centerAliendoesn’t really need to be modified for the splitting process; really, all we need to do is spawn two newAliens at the right angle and velocity so that it appears we’ve turned the singleAlieninto three, one above and one below. For this, you’ll need to take linear velocity into consideration. Additionally, be aware that theAlienwe want to launch has theuserDataof the string “Player”, as opposed to theAlienwe want to kill, which has just theuserDataof “Alien”. Lastly, be sure that the launch marker doesn’t reset until all of theAliens we fling have slowed to nearly being still, not just the oneAlienwe normally check. In all, you should have all of the pieces at this point you need in order to make this happen; best of luck!
How to Submit
Step 1 of 1
- Go to the GitHub page for your username/assignment6-username repository (note: this is different from the games50/assignment6-username repository).
- On the right side of the screen, click the Pull request button.
- Make sure that the “base fork” is
games50/assignment6-username, and the “head fork” isusername/assignment6-username. - Click “Create pull request”.
- On the next page, click the “Create pull request” button again.
Congratulations! You’ve completed Assignment 6.