June 2021
Beginner
344 pages
8h 9m
English
The MapBuilder needs to know what theme you’re associating with your newly designed map. Open map_builder/mod.rs, and add a theme to the MapBuilder:
| | const NUM_ROOMS: usize = 20; |
| | pub struct MapBuilder { |
| | pub map : Map, |
| | pub rooms : Vec<Rect>, |
| | pub monster_spawns : Vec<Point>, |
| | pub player_start : Point, |
| | pub amulet_start : Point, |
| | pub theme : Box<dyn MapTheme> |
| | } |
If you’re using an IDE, it probably just highlighted all of your map builders as compilation errors. These errors happen because you’ve extended MapBuilder to include a new field. Rust requires that you initialize every field in a struct on creation—uninitialized fields are a common source of bugs ...
Read now
Unlock full access