Building a Dungeon
You’ve built an empty map and have a player who can walk around it. The structure is in place to handle walls, so it’s time to add a simple dungeon. In this section, you’ll learn to randomly place rooms, connect them with corridors, and build a dungeon for your adventurer to explore.
Create a Map Builder Module
Make another new file named map_builder.rs. This file will contain the map building module. Add it to your prelude in main.rs:
| mod map; |
» | mod map_builder; |
| mod player; |
| |
| mod prelude { |
| pub use bracket_lib::prelude::*; |
| pub const SCREEN_WIDTH: i32 = 80; |
| pub const SCREEN_HEIGHT: i32 = 50; |
| pub use crate::map::*; |
| pub use crate ... |
Get Hands-on Rust now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.