diff options
| author | Yusuf Elsharawy <yusufse-2004@hotmail.com> | 2025-11-10 20:22:35 +0000 |
|---|---|---|
| committer | Yusuf Elsharawy <yusufse-2004@hotmail.com> | 2025-11-10 20:22:35 +0000 |
| commit | 16a486f46dcf4525e52844ef03fa5e9cb7e6660f (patch) | |
| tree | b43d63934ba0e26237fc8e0548d18282987343db /dungeon | |
| parent | Fixed `Game` methods' returns (diff) | |
| download | DungeonCrawl-16a486f46dcf4525e52844ef03fa5e9cb7e6660f.tar.gz DungeonCrawl-16a486f46dcf4525e52844ef03fa5e9cb7e6660f.tar.bz2 DungeonCrawl-16a486f46dcf4525e52844ef03fa5e9cb7e6660f.zip | |
Added player movement check for walkab;e tiles
Diffstat (limited to 'dungeon')
| -rw-r--r-- | dungeon/src/lib.rs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/dungeon/src/lib.rs b/dungeon/src/lib.rs index 399807c..adc053e 100644 --- a/dungeon/src/lib.rs +++ b/dungeon/src/lib.rs @@ -89,7 +89,13 @@ impl Dungeon { (None, Some(dir)) => { // set direction & find out next position self.player.entity.dir = dir; - self.player.moving_to = self.player.entity.pos.step(dir); + if let Some(pos) = self.player.entity.pos.step(dir) + && self.floor.get(pos).is_walkable() + { + self.player.moving_to = Some(pos); + } else { + break; + } } (None, None) => break, } |