Assignment 6: Pokémon
- 💯 Worth: 6%
- 📅 Due: See due date on Moodle.
- 🚫 Penalty: Late submissions lose 10% per day to a maximum of 3 days. Nothing is accepted after 3 days and a grade of 0% will be given.
🎯 Objectives
Section titled “🎯 Objectives”- Read and understand all of the Pokémon tutorial lessons.
- Extend an existing codebase by reading its conventions and building new features that fit into them.
- Use a state stack for screens and overlays, and state machines for characters.
- Write timed sequences with
asyncandawaitso they read top to bottom in one place. - Drive the game from config, so new moves, maps, characters, and story beats are data, not new
ifbranches. - Give the player feedback through sound effects, music, and visual effects.
🔨 Setup
Section titled “🔨 Setup”- Fork (do not download as a zip) the starter repository from GitHub. Make sure you use the link from Moodle to fork the proper repository for this assignment.
- Follow the environment setup instructions if you haven’t already done so from a previous assignment.
- Start Live Server in VSC by right-clicking on
index.htmland selecting Open with Live Server. This will open a new tab in your browser with the game running.
🔍 Context
Section titled “🔍 Context”To complete this assignment, you should read and understand all of the Pokémon tutorial lessons, and be familiar with the following:
- The stack is for screens: only the top state updates, and every state draws, bottom to top. A new screen is
await TransitionState.cover(), thenpushorpop, thenawait TransitionState.uncover(). Look atPlayState.startBattle(). - Overlays close themselves:
DialogueState.show(),PokemonStatsState.show(), andbattle.showMessage()put anOverlayStateon top and return a promise that resolves when it callsclose(). Neverpushorpopan overlay yourself. - A state machine is for characters:
PlayerandNPCare in exactly one state at a time, and each state owns its animation and drawing. asyncandawait:awaitpauses only the function it’s in, while the game loop keeps running frames.BattleState.fight()andBattleTurn.fight()read top to bottom because every step is awaited. Usevoidwhen nothing waits for the result, asPlayerWalkState.handleMovement()does.- Config: Pokémon and moves live in
src/config/pokemon.js, NPCs insrc/config/characters.js, signs insrc/config/signs.js, and each map’s areas and music insrc/config/areas.js. Maps are Tiled’s own.tmjfiles inassets/maps/.
Welcome to your seventh (and final) assignment! We’ve built the core of a Pokémon game in the style of FireRed, with a town to walk around, people to talk to, tall grass full of wild Pokémon, and turn-based battles that level up your partner. Now it’s time to choose where to take it: deeper battles, a bigger world, or a story to play through.
The World
Section titled “The World”The starter’s overworld is Pallet Town at the bottom and Route 1 at the top:
| Place | What’s there |
|---|---|
| Pallet Town | The player’s house (left), the rival’s house (right), and Oak’s lab (bottom right). A new game starts at (6, 49). |
| The path north of town | The two path tiles at (12, 40) and (13, 40), between the town and Route 1’s tall grass. |
| Route 1 | Tall grass with wild Pidgey and Rattata, the ledges, and an open spot on the left for a trainer. |
player-house-1f.tmj and the other interiors |
Already drawn in Tiled, but not used until you implement the 🚪 Interiors and Doors major. |
Positions are in tiles, counted from the top left of the map. Set SHOW_TILE_GRID to true in src/config/game.js to see the grid while you work.
Edit the Tilemap (Optional)
Section titled “Edit the Tilemap (Optional)”You don’t have to edit any map, since everything every feature needs is already on them. If you want to:
- Download the Tiled map editor from here.
- Open any
.tmjfile inassets/maps/. Keep the three layers, Bottom (ground), Collision (anything solid), and Top (anything the player walks behind). - Save, then refresh the game. The game loads the
.tmjfiles as they are, so there’s no export step.
✅ Pick 1/3 Feature Sets (90%)
Section titled “✅ Pick 1/3 Feature Sets (90%)”Pick one of the ⚔️ Battle, 📍 Exploration, or 📖 Story feature sets. Implement both of its minor features (30%) and both of its major features (60%). The features in a set build on each other, so you can’t mix features from different sets.
Each feature’s table lists everything it’s graded on. Each row is worth 2 points: 2 if it works fully, 1 if it partially works, and 0 if it doesn’t work or wasn’t attempted. Name your feature set in your README. Additional deductions may be given for other issues, which will be detailed in comments.
⚔️ Battle Feature Set
Section titled “⚔️ Battle Feature Set”Get away from battles, see what a level up gave you, and fight with real moves and types.
Minor: 🏃 Run
Section titled “Minor: 🏃 Run”Choosing RUN gets the player out of a wild battle, if their Pokémon is fast enough.
| Requirement | How it’s tested |
|---|---|
Choosing RUN in a wild battle shows “Got away safely!” and returns to the map. |
Run from a battle with a faster Pokémon. |
Running away plays battle-run.ogg. |
Run from a battle. |
| Escape can fail, with odds based on the two Pokémon’s Speed. | Run from a faster wild Pokémon several times. |
| A failed escape shows “Can’t escape!” and the opponent takes its turn. | Fail to run and watch the opponent attack. |
BAG and POKéMON show “That isn’t available yet.” and return to the menu. |
Choose each one. |
Minor: 🧮 Stat Change Panel
Section titled “Minor: 🧮 Stat Change Panel”After a level up, a panel shows how much each stat went up, then the new totals.
| Requirement | How it’s tested |
|---|---|
| After the “grew to LV.” message, a panel opens over the battle. | Win a battle that levels you up. |
The first page lists Max. HP, Attack, Defense, and Speed, each with its gain, such as + 2. |
Read the first page. |
Enter shows the second page, with each stat’s new total. |
Press Enter on the first page. |
Enter closes the panel, and the battle continues. |
Press Enter on the second page. |
| The new totals match the stats screen. | Press Escape on the map after the battle and compare. |
Major: 💥 Moves
Section titled “Major: 💥 Moves”Each Pokémon knows up to four moves, each with its own power, type, PP, and sound.
| Requirement | How it’s tested |
|---|---|
FIGHT opens a 2×2 menu listing the Pokémon’s moves. |
Choose FIGHT with each starter. |
| Empty slots show a hyphen and can’t be selected. | Try to select an empty slot. |
| A side panel shows the highlighted move’s PP (current and max) and type. | Move the cursor over each move. |
Escape goes back to the battle menu. |
Open the move menu and press Escape. |
| Using a move spends 1 PP. | Use a move and check its PP the next turn. |
A move with 0 PP can’t be chosen, and plays player-bump instead. |
Use up a move’s PP, then try to choose it. |
Healing (P, or fainting) refills every move’s PP. |
Spend some PP, heal, and check it. |
| Each move plays its own sound, and the opponent picks one of its moves at random. | Use each move, and watch the opponent over several turns. |
📋 Moves to add
| Move | Type | Power | PP | Sound |
|---|---|---|---|---|
| Tackle | Normal | 40 | 35 | SoundName.Tackle |
| Ember | Fire | 40 | 25 | MoveSound.Ember |
| Water Gun | Water | 40 | 25 | MoveSound.Bubble |
| Vine Whip | Grass | 45 | 10 | MoveSound.DoubleSlap |
| Thunderbolt | Electric | 90 | 15 | MoveSound.Thunderbolt |
| Flamethrower | Fire | 90 | 15 | MoveSound.Flamethrower |
| Hydro Pump | Water | 110 | 5 | MoveSound.HydroPump |
| Solar Beam | Grass | 120 | 10 | MoveSound.SolarBeam |
Thunderbolt, Flamethrower, Hydro Pump, and Solar Beam are there to fill a fourth slot, or to give an opponent something strong. None of them is tested on its own.
Major: 🔥 Types and Animations
Section titled “Major: 🔥 Types and Animations”Moves are strong or weak against the defender’s type, and damaging moves play their own animation.
| Requirement | How it’s tested |
|---|---|
| A super effective hit does double damage and shows “It’s super effective!” | Use Ember on Bulbasaur. |
| A not very effective hit does half damage and shows “It’s not very effective…” | Use Ember on Squirtle. |
Super effective, regular, and not very effective hits play hit-super-effective.wav, hit-regular.wav, and hit-not-effective.wav. |
Land each kind of hit. |
| Effectiveness follows the type chart below for every pairing of Fire, Water, and Grass. | Use each starter’s type move against each starter. |
| Ember, Water Gun, and Vine Whip each play their own animation. | Use each move. |
| Animations play over the target, both from the player toward the opponent and the reverse. | Use the moves, and let an opponent that knows them use them on you. |
| The hit lands only after both the animation and the sound finish. | Watch when the health bar starts to drop. |
| A move with no animation lunges instead, as Tackle does now. | Use Tackle. |
Every pairing not in this type chart is 1×:
| Move type ↓ / Defender type → | Fire | Water | Grass |
|---|---|---|---|
| Fire | 0.5× | 0.5× | 2× |
| Water | 2× | 0.5× | 0.5× |
| Grass | 0.5× | 2× | 0.5× |
| Electric | 1× | 2× | 1× |
📍 Exploration Feature Set
Section titled “📍 Exploration Feature Set”Hop down ledges, see where you are, go inside, and get stopped by a trainer.
Minor: ⛰️ Ledges
Section titled “Minor: ⛰️ Ledges”The ledges on Route 1 are one-way, so the player hops down them but can’t climb back up.
| Requirement | How it’s tested |
|---|---|
| Walking south onto a ledge hops the player over it. | Walk down into each ledge on Route 1. |
| The hop lands two tiles down, on the tile past the ledge. | Count the tiles with SHOW_TILE_GRID on. |
| The hop arcs up and down, with a shadow on the ground. | Watch a hop. |
The hop plays ledge.wav. |
Hop a ledge. |
| Ledges block walking from every other direction. | Walk into a ledge from below and from each side. |
Minor: 🪧 Area Name Banner
Section titled “Minor: 🪧 Area Name Banner”A banner slides down with the area’s name whenever the player walks into a new outdoor area.
| Requirement | How it’s tested |
|---|---|
| Walking from Pallet Town into Route 1, or back, slides down a banner with the area’s name. | Walk up the path and back down. |
| Going into a building shows no banner, and coming back out names the area again. | Go into a house and come back out. |
| The banner holds for about 2 seconds, then slides back up. | Time it. |
| Moving around inside the same area doesn’t show it again. | Walk around town after the banner leaves. |
| Entering a new area while a banner is showing replaces it straight away. | Step back and forth across the border. |
Major: 🚪 Interiors and Doors
Section titled “Major: 🚪 Interiors and Doors”The three buildings in Pallet Town have insides, and the player’s house has an upstairs.
| Requirement | How it’s tested |
|---|---|
Walking up into a door from its doormat opens the door and plays door-enter.wav. |
Walk up into each door. |
| The player walks into the doorway, the screen fades, and the player appears on the inside mat. | Go into each building. |
Walking down off the inside mat fades back to town and plays door-exit.wav. |
Leave each building. |
| Outside, the player starts on the open door, walks down, and the door closes. | Leave each building. |
| Each of the three doors leads to the right interior and back to the same door. | Go in and out of every building. |
| The stairs in the player’s house lead to the upper floor and back down. The player arrives on the stairs and walks off them. | Take the stairs both ways. |
| Oak’s lab plays its own music, the houses keep the town’s, and the town music resumes outside. | Go into Oak’s lab and back out. |
| The town keeps its state while the player is inside, and input is ignored during transitions. | Watch the NPC’s spot after leaving, and hold keys while fading. |
📋 Warps
| Warp | Map | Tile | Leave it going | Leads to |
|---|---|---|---|---|
| Player’s house, outside mat | overworld |
(6, 48) | up | Player’s house, inside mat |
| Player’s house, inside mat | playerHouse1F |
(4, 8) | down | Player’s house, outside mat |
| Rival’s house, outside mat | overworld |
(15, 48) | up | Rival’s house, inside mat |
| Rival’s house, inside mat | rivalHouse |
(4, 8) | down | Rival’s house, outside mat |
| Oak’s lab, outside mat | overworld |
(16, 54) | up | Oak’s lab, inside mat |
| Oak’s lab, inside mat | oaksLab |
(6, 12) | down | Oak’s lab, outside mat |
| Stairs up landing | playerHouse1F |
(10, 2) | right | Stairs down landing |
| Stairs down landing | playerHouse2F |
(10, 2) | left | Stairs up landing |
Major: 🧢 Trainers
Section titled “Major: 🧢 Trainers”A trainer on Route 1 battles the player on sight.
| Requirement | How it’s tested |
|---|---|
The trainer spots the player when they step into its line of sight, straight ahead and up to its sight in tiles. |
Walk across its line at different distances. |
| Walls and other characters block its line of sight. | Stand behind a wall or another character in its line. |
| A “!” bubble appears over the trainer, and the player stops. | Step into its line. |
| The trainer walks up to the player and says its line before the battle. | Step into its line from a few tiles away. |
| The battle opens with “YOUNGSTER BEN wants to battle!” and “YOUNGSTER BEN sent out SQUIRTLE!”, against the party in its config. | Check the trainer’s name, and the opponent’s name and level. |
| Winning shows the trainer’s defeat line in the battle, then returns to the map with the trainer still standing there. | Beat the trainer. |
| After winning, the trainer says its after-battle line when talked to. | Talk to the trainer. |
| A defeated trainer never battles again, even after leaving the map and coming back. | Walk through its line again, and again after going into a house. |
📋 Trainer config for a new src/config/trainers.js
{ id: "youngsterBen", name: "YOUNGSTER BEN", position: { x: 3, y: 30 }, direction: Direction.Right, firstSprite: { x: 9, y: 292 }, totalSprites: 12, sight: 5, party: [{ name: "Squirtle", level: 3 }], beforeText: "Hey! You look new around here. Let's battle!", defeatText: "Aww, I lost!", afterText: "I'm going to train in the tall grass until I'm as strong as you.",},📖 Story Feature Set
Section titled “📖 Story Feature Set”Bring Pallet Town to life, and give the player a story to start and a way to come back to it.
Minor: 🚶 Town NPC
Section titled “Minor: 🚶 Town NPC”The NPC in Pallet Town wanders around instead of standing still.
| Requirement | How it’s tested |
|---|---|
| The NPC wanders, taking single tile steps at random times. | Watch the NPC for a while. |
| It turns to face random directions between steps. | Watch the NPC for a while. |
| It stays inside its area. | Watch the NPC with SHOW_TILE_GRID on. |
| It never walks through walls, the player, or other NPCs. | Stand in its way. |
| It stops while talking and faces the player. | Talk to it from each side, including mid-step. |
Minor: 💬 Dialogue Rules
Section titled “Minor: 💬 Dialogue Rules”What an NPC says depends on what has happened in the story so far.
| Requirement | How it’s tested |
|---|---|
An NPC’s dialogue in characters.js is a list of rules, the first rule whose when matches the story is used, and a rule with no when is the fallback. |
Read src/config/characters.js, and talk to the town NPC in a new game. |
Talking can set a story flag, with a rule’s sets. |
Talk to the town NPC twice in a new game. |
| The town NPC first sends the player to fight a wild Pokémon, then urges them on each time after. | Talk to the town NPC several times in a new game. |
Winning a wild battle sets beatWildPokemon, and then the town NPC compliments the player. |
Win a wild battle, then talk to the town NPC. |
| Losing a wild battle doesn’t set it. | Lose a wild battle in a new game, then talk to the town NPC. |
📋 The town NPC’s new dialogue
dialogue: [ { when: { beatWildPokemon: true }, text: "Wow, you beat a wild POKEMON! You're a natural trainer!", }, { when: { toldToBattle: true }, text: "What are you waiting for? The tall grass is to the north!", }, { sets: { toldToBattle: true }, text: "Welcome to Pallet Town! Go fight a wild POKEMON in the tall grass to the north!", },],Major: 🎬 Oak’s Scene
Section titled “Major: 🎬 Oak’s Scene”The first time the player heads for the tall grass, Professor Oak stops them and hands over a starter.
| Requirement | How it’s tested |
|---|---|
| Walking onto either path tile at (12, 40) or (13, 40) for the first time starts the scene. | Start a new game and walk north on each side of the path. |
| The player can’t move during the scene. | Hold the arrow keys during the scene. |
| Oak walks up from off screen to the player. | Watch the scene. |
| Oak gives his speech. | Read the speech. |
| Oak offers the three starters through a menu, and the chosen Pokémon becomes the player’s starter. | Choose each starter in different games, then press Escape. |
| Oak walks back off screen. | Watch the end of the scene. |
| Town NPC knows you’ve spoken to Oak. | Talk to the town NPC after the scene, before winning a wild battle. |
| The scene never plays again, including after saving and continuing. | Walk over the path tiles again, and after continuing if you’ve done 💾 Saving. |
📖 How the town NPC’s lines change
The first rule that matches wins, so the order is what makes each line take over from the one before:
| Order | when |
Line |
|---|---|---|
| 1 | { beatWildPokemon: true } |
“Wow, you beat a wild POKEMON! You’re a natural trainer!” |
| 2 | { metOak: true } |
“You got a POKEMON from PROF.OAK? Wild POKEMON live in…” |
| 3 | { toldToBattle: true } |
“What are you waiting for? The tall grass is to the north!” |
| 4 | none (sets toldToBattle) |
“Welcome to Pallet Town! Go fight a wild POKEMON in…” |
Every way to the tall grass crosses Oak’s tiles, so Oak always comes before the first wild battle. Each box is what the town NPC says if the player talks to it now, starting from a new game:
flowchart LR A["Welcome to Pallet Town!"] -- talk --> B["What are you waiting for?"] A -- "Oak's scene" --> C B -- talk --> B B -- "Oak's scene" --> C["You got a POKEMON from PROF.OAK?"] C -- "lose a wild battle" --> C C -- "win a wild battle" --> D["You beat a wild POKEMON!"]
📋 Oak’s rule for the town NPC, and his speech
The town NPC’s metOak rule:
{ when: { metOak: true }, text: "You got a POKEMON from PROF.OAK? Wild POKEMON live in the tall grass on ROUTE 1!",},Oak’s speech, if you want it:
Ah, there you are! I've been expecting you, game programming student!Welcome to my world... or what's left of it. No gyms, no POKEMON League, just one town and one route. Yes, this is a stripped-down version of the real game.But look closer! Screens on a stack, characters in state machines, battles played out one step at a time. It's all here for you to read.Your very own adventure is about to begin! You won't be catching POKEMON. You'll be building this world, one feature at a time.Now go! Your assignment awaits!Major: 💾 Saving
Section titled “Major: 💾 Saving”The player can save on the map and continue from the title screen.
| Requirement | How it’s tested |
|---|---|
Enter on the map opens a SAVE / CLOSE menu, and CLOSE closes it. |
Press Enter while standing still, and choose CLOSE. |
SAVE saves the game and plays save.wav. |
Choose SAVE. |
The title screen offers CONTINUE and NEW GAME only when a save exists. |
Load the game before and after saving. |
NEW GAME starts fresh, even when a save exists. |
Save, refresh, and choose NEW GAME. |
CONTINUE puts the player back on the same map and tile, facing the same way. |
Save somewhere unusual, refresh, and continue. |
CONTINUE restores the party’s Pokémon, levels, HP, and experience. |
Save after a few battles, refresh, continue, and press Escape. |
CONTINUE restores the story flags. |
Save after Oak’s scene, refresh, continue, and walk over the path tiles. |
| Saving again overwrites the old save, and a refresh keeps it. | Save in two places, refresh, and continue. |
📝 Assignment Policies (10%)
Section titled “📝 Assignment Policies (10%)”Read the assignment policies and make sure you include a proper .devlog.md file (5%). There will be a peer evaluation component (5%) to this assignment as well as a chance to be randomly selected to do a code walkthrough at my discretion.
📥 Submission
Section titled “📥 Submission”- Inside README.md, name the feature set you implemented, then any known bugs to look out for, anything you want your peer evaluators to know, then do your final
git pushto GitHub. - Go to Gradescope, click the link for this assignment, select the correct repository and branch from the dropdown menus, and click
Upload. - Assess your peers starting the day after the three day late submission deadline.