Pokémon
Objectives
- Read and understand all of the Pokémon source code from Lecture 7.
- Implement a
Menu
that 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. ThisMenu
should appear right after the “Level Up” dialogue that appears at the end of a victory where the player has indeed leveled up.
Demo
by Edward Kang
Getting Started
Download the distro code for your game from cdn.cs50.net/games/2018/x/projects/7/pokemon.zip and unzip pokemon.zip
, which should yield a directory called pokemon
.
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 pokemon
(recall that the cd
command can change your current directory), and run
cd pokemon
Next-Level
Welcome to your eighth assignment! This week’s code will probably be the most complicated we’ll look at during the semester, but the assignment itself is fairly small in comparison; you will, however, need to know how many of the pieces work and fit together in order to accomplish the task ahead.
Specification
- Implement a
Menu
that 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. ThisMenu
should 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 aBattleMessageState
gets pushed onto theStateStack
, but we’ll need to go a step further and push an additionalMenu
in order to accomplish what we’re after. ThisMenu
should not have a cursor like the otherMenu
we’re used to seeing (in theBattleMenuState
!), so you’ll need to customize theSelection
class a little bit in order to take a boolean value to turn the cursor on or off as needed (defaulting totrue
if needed to preserve the behavior of theMenu
in theBattleMenuState
). Note that the:levelUp()
function in thePokemon
class 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
! As long as you get a proper grasp on theSelection
,Menu
, andStateStack
classes, this assignment should be relatively straightforward in comparison to the complexity of this week’s code as a whole!
CS50 Games exists only in archive form, as of 1 July 2024. While you cannot submit this project for credit any longer, it is a great exercise to test your understanding of the course material.