diff options
Diffstat (limited to 'src/world.rs')
-rw-r--r-- | src/world.rs | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/world.rs b/src/world.rs index a315111..451b091 100644 --- a/src/world.rs +++ b/src/world.rs @@ -50,10 +50,13 @@ impl Room { impl Tileable for Room { fn tile(&self, grid: &mut TileGrid) -> Result<(), String> { - // TODO: Detect if the room would leave the grid. let endx = self.start.0 + self.width; let endy = self.start.1 + self.height; + if endx >= grid.xsize() || endy > grid.ysize() { + return Err(String::from("Room outside of grid bounds")); + } + // Set the walls for x in self.start.0..=endx { grid.set_empty_tile(x, self.start.1, TileType::Wall); |