Introduction to Take Turns with the Monsters

Get a brief introduction to what we’ll learn in this chapter.

We'll cover the following

In the previous chapter, we extended our game to use an Entity-Component System (ECS). We added monsters and a simple collision detection system to remove monsters from the dungeon when you bump into them. The monsters remained static, quietly awaiting their demise.

What will we learn?

In this chapter, we’ll make the monsters move randomly. The game will then too fast to play, so we’ll implement a turn-based game flow similar to Nethack1 or Dungeon Crawl: Stone Soup. We’ll learn to selectively schedule systems execution based upon turn state and move to an intent-based system allowing for greater complexity, such as movement being canceled by being stunned.

We’ll extend the ECS system to allow monsters to move. We’ll then create the turn-based gameplay by tracking the current turn state and dividing the system scheduler into multiple parts. We’ll also move beyond directly writing to the game state by implementing messages indicating intent so that later systems can process them. Using an intent-based messaging system will remove duplicate code, reduce dependencies between systems, and grant future flexibility.

Get hands-on with 1200+ tech skills courses.