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
Download the distro code for your game from cdn.cs50.net/games/2020/fall/assignments/6/assignment6.zip and unzip assignment6.zip, which should yield a directory called assignment6.
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 assignment6 (recall that the cd command can change your current directory), and run
cd assignment6
Three’s Company
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.
Specification
- 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!
Errata
NONE
How to Submit
Step 1 of 2
- Download the README.md template.
- Fill out all
TODOentries in the template as appropriate, and mark a self-assessment of your design score. Then, save yourREADME.mdfile. - Go to CSCI E-23a’s Gradescope page.
- Click Project 6: Angry Birds.
- Drag and drop your downloaded
README.mdfile to the area that says “Drag & Drop”. - Click Upload.
Step 2 of 2
- Download a ZIP file of your
assignment6directory, containing your implementation of this project. - Upload your submission via our Dropbox file request for this project.
- Click Add files, then Files from your computer and select your previously downloaded file.
- Click Upload.
You should see a message that your file finished uploading and that we were notified of your uploaded files. Contact your teaching fellow if not!
Your submission is not considered complete until BOTH of the above steps are complete. Omitting either step is equivalent to not submitting the project at all.
Late-submitted work will be flagged in both the Dropbox file request and on Gradescope, and any late penalty assessed will be based on whichever of the two steps was completed the latest.