Pokémon
Objectives
- Implement a
Menuthat appears during the player Pokémon’s level up. - Implement a UI enabling a player to view their full party of Pokémon.
- Allow a player to “catch ‘em all!” (well, up to six!)
Getting Started
Download the distribution code for your game from cdn.cs50.net/2d/2025/x/projects/7/pokemon.zip and unzip pokemon.zip, which should yield a directory called pokemon.
Then, in a terminal window, move to the directory where you extracted pokemon, and run
cd pokemon
Next-Level
This project’s code will probably be the most complicated we’ll look at, but the assignment itself is not as big as it might first appear; you will, however, need to know how many of the pieces work and fit together in order to accomplish the tasks ahead.
Specification
-
Implement a
Menuthat appears during the player Pokémon’s level up that shows, for each stat, ‘X + Y = Z’, where X is the starting stat, Y is the amount it’s increased for this level, and Z is the resultant sum. ThisMenushould appear right after the “Level Up” dialogue that appears at the end of a victory where the player has indeed leveled up. The area where most of this will take place is theTakeTurnState, specifically in the:victory()function, where the actual detection of a level up takes place. Ordinarily, just aBattleMessageStategets pushed onto theStateStack, but we’ll need to go a step further and push an additionalMenuin order to accomplish what we’re after. ThisMenushould not have a cursor like the otherMenuwe’re used to seeing (in theBattleMenuState!), so you’ll need to customize theSelectionclass a little bit in order to take a boolean value to turn the cursor on or off as needed (defaulting totrueif needed to preserve the behavior of theMenuin theBattleMenuState). Note that the:levelUp()function in thePokemonclass returns all of the stat increases we need in order to display things properly, so be sure to use those returned values when creating theMenu! -
When in the field, allow the player to press some key to open up a UI that enables them to look at their party of Pokémon (it should show them visually, as well as their stats). Currently, it’s a bit hard to see information on how strong our creatures are when we’re not in combat. And spoiler alert, we’ll need this ability all the more soon in the coming tasks! But for right now, implement it such that when pressing some key (like “M” for “Menu”), a new state gets pushed on our
StateStack(let’s call it theCreatureSummaryState) that functions not all that dissimilar to what’s called the “Summary” panel in the actual Pokémon games. For now, we just have one creature that we started out with, but we’ll want this new UI to be capable of showing more than one very soon, so keep that in mind! The specific design is up to you, but be sure that for any creature in ourPartyit’s possible to see the front image of the creature itself, its name, its level, and its stats all at the same time, and that we can page through each individual creature in ourPartyby pressing the Left or Right arrow keys. Ensure that it’s clear how many creatures are in ourPartyoverall and which creature index-wise that we’re looking at currently as well; you may use a UI element of your choice to convey this, be it a text label, a set of circular icons, etc. -
Allow the player to “catch” a Pokémon via a new menu option in combat that will only succeed if the enemy Pokémon has <= 25% HP. As alluded to above, just one creature isn’t quite exciting enough in the world of Pokémon (or our knockoff thereof!). Indeed, “catch ‘em all” is the famous slogan for a reason, and we’ll want to ensure that we have the ability to now do so ourselves. Add an option to our battle menu called “Catch” that, should our opponent have <= 25% of its max HP at the time we select “Catch” (meaning we will have to do sufficient damage to it in combat to weaken it), this will result in a successful catch, whereby that creature, if we have <= 5 creatures in our
Party(allowing for 6 total), is caught and added to our collection, then ending the combat with no experience gain. This should then be reflected per the task just above this one, where in the field we’re able to view our party at any time by paging through ourCreatureSummaryStatewith max 6 creatures. For the actual catch animation, do feel free to take some creative liberties; the only requirement is that they do not fall down through the game window as they normally do when defeated, but should instead visually do something else (an easy potential option is to make them transparently fade out in-place). And do be sure that trying to “Catch” the Pokémon when it does not have <= 25% HP fails; how you go about this is up to you, be it through a menu popup, greying out the option, etc., as long as it’s indeed non-functional until that HP threshold has been crossed. Be sure also that if we already have 6 creatures, the option similarly does not work and we get a different message indicating as much.
Errata
NONE
How to Submit
When you submit your project, the contents of your 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 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/2025/x/pokemon/src/states/game/BattleState.lua (where USERNAME is your own GitHub username as provided in the form, below) we should be brought to your BattleState.lua file for Pokémon. 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. Code improperly organized will not be eligible for a passing score.
- If you haven’t 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.
-
Install Git and, optionally, install
submit50. -
Using Git, push your work to
https://github.com/me50/USERNAME.git, whereUSERNAMEis your GitHub username, on a branch calledgames50/projects/2025/x/pokemonor, if you’ve installedsubmit50, executesubmit50 games50/projects/2025/x/pokemoninstead.
-
Record a screencast, not to exceed 5 minutes in length in which you demonstrate your game’s functionality. Upload that video to YouTube (as unlisted or public, but not private). This video’s requirements are:
- It is not a YouTube “short”.
- The video begins with a slide or text overlay containing both your edX and GitHub usernames.
- It must show your game live and in action. Do not use this video to walk us through any code.
- It demonstrates that all three (3) items of the specification have been implemented.
- The video description has been timestamped at the (first) point where your video demonstrates each of the above-referenced implementations.
- The video has been uploaded less than one month from the time of your submission of the form for this project (the final step below).
- Submit this form.
You can then go to https://cs50.me/cs502d to view your current progress!