Chapter 5 Build a Dungeon Crawler
Hands-on Rust — by Herbert Wolverson (42 / 120)
👈 Wrap-Up | TOC | Dividing Your Code Into Modules 👉
In the previous chapter, you designed a dungeon crawler game. In this chapter, you’ll start assembling the building blocks that make up the design, leaving you with an adventurer able to walk around a randomly generated dungeon. You’ll start by dividing your code into modules, taming complexity as the program grows — and helping you isolate bugs. You’ll then learn to store a map in a structure of tiles, and how this leads to an efficient and simple map rendering system. Your next step is to add a player and make them move around the map — including not walking through walls. Finally, you’ll implement a random map generation system — carving out a dungeon similar to the original Rogue or Nethack. Mastering these building blocks will give you the know-how you need to make tile-based games — you can draw a tile map, and the player can navigate it.
All of your code so far has been contained in a single main.rs file. As your game grows, you’ll find it easier to put similar code together in modules.
👈 Wrap-Up | TOC | Dividing Your Code Into Modules 👉
Hands-on Rust by Herbert Wolverson can be purchased in other book formats directly from the Pragmatic Programmers. If you notice a code error or formatting mistake, please let us know here so that we can fix it.