Download the distro code for your first game from https://cdn.cs50.net/games/2019/x/assignments/5/assignment5.zip and unzip
assignment5.zip, which should yield a directory called
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
(recall that the
cd command can change your current directory), and run
Welcome to your sixth assignment! We’ve explored the workings of a top-down adventure game in the style of Legend of Zelda and have a fair foundation for anything resembling it, be it a dungeon crawler or a vast 2D game featuring an overworld or the like. Let’s add a few pieces to this sample in order to pay homage to some of the classic Zelda titles and to give our character a shot at actually surviving his trek through the dungeon!
Your goals this assignment:
healthfield, including the
Player’s health is measured numerically but represented via hearts; note that he can have half-hearts, which means that each individual heart should be worth 2 points of damage. Therefore, when we want to heal the
Playerfor a full heart, be sure to increment health by 2, but be careful it doesn’t go above the visual cap of 6, lest we appear to have a bug! Defining a
GameObjectthat has an
onConsumecallback is probably of interest here, which you can refer back to Super Mario Bros. to get a sense of, though feel free to implement however best you see fit!
GameObjects, which should be collidable such that the
Playercan’t walk through them. When he presses a key in front of them, perhaps
return, he should lift the pot above his head with an animation and then transition into a state where he walks around with the pot above his head. This will entail not only adding some new states for the
Playerbut also ensuring a link exists (pun intended) between a pot and the character such that the pot always tracks the player’s position so it can be rendered above his head. Be sure the
Playercannot swing his sword while in this state, as his hands are full!
Playerto throw the pot, effectively turning it into a projectile, and ensure it travels in a straight line depending on where the
Playeris facing when they throw it. When it collides with a wall, an enemy, or if it travels farther than four tiles in that direction, the pot should shatter, disappearing (although an actual shatter animation is optional). If it collides with an enemy, ensure the pot does 1 point of damage. There are many ways you can achieve this; think about how you can extend
GameObjectto fit this use case, perhaps adding a
projectilefield and therefore a
GameObjectto allow it to have traveling functionality. Perhaps include a
:firemethod as part of
GameObjectthat will trigger this behavior as by passing in said
dyinstead. The choice is yours, but
GameObjectis flexible enough to make it work!
Using Git, push your work to
USERNAME is your GitHub username, on a branch called
games50/assignments/2019/x/5 or, if you’ve installed