Transitioning between levels is a great start, but it’s helpful to know what level the player is on. We need this information to determine if we should spawn the Amulet of Yala or an exit. We’ll use the current dungeon level later to present the player with their progress through the dungeon, providing a sense of progress. The current level will also be used in the next chapter to spawn increasingly difficult monsters and better loot as the adventurer progresses.

Let’s start by adding the current dungeon level to the Player component. The adventurer is the only entity advancing through the dungeon, so the Player component is a good place to store the current map level. Add a map_level field to the Player component in components.rs:

Get hands-on with 1200+ tech skills courses.