diff options
| author | Freya Murphy <freya@freyacat.org> | 2025-10-07 12:01:47 -0400 |
|---|---|---|
| committer | Freya Murphy <freya@freyacat.org> | 2025-10-08 19:37:16 -0400 |
| commit | b23cdda680badc82149efac997840740213dbfbc (patch) | |
| tree | 4eb087492f30c621646b16a42cd25be2e9be8526 /dungeon | |
| parent | impl default to dungeon and its types (diff) | |
| download | DungeonCrawl-b23cdda680badc82149efac997840740213dbfbc.tar.gz DungeonCrawl-b23cdda680badc82149efac997840740213dbfbc.tar.bz2 DungeonCrawl-b23cdda680badc82149efac997840740213dbfbc.zip | |
add more default impls
Diffstat (limited to 'dungeon')
| -rw-r--r-- | dungeon/src/map.rs | 4 | ||||
| -rw-r--r-- | dungeon/src/pos.rs | 6 |
2 files changed, 8 insertions, 2 deletions
diff --git a/dungeon/src/map.rs b/dungeon/src/map.rs index b6f3356..cb602e8 100644 --- a/dungeon/src/map.rs +++ b/dungeon/src/map.rs @@ -190,8 +190,8 @@ impl Floor { impl Default for Floor { /// Returns a floor with a single set of walls on the map border fn default() -> Self { + const PLAYER_START: Pos = Pos::new_const::<1, 1>(); let mut tiles = Box::new([Tile::Air; TILE_COUNT]); - let player_start = Pos::new_const::<1, 1>(); let seed = 0u64; for pos in Pos::values() { @@ -202,7 +202,7 @@ impl Default for Floor { Self { tiles, - player_start, + player_start: PLAYER_START, seed, } } diff --git a/dungeon/src/pos.rs b/dungeon/src/pos.rs index 143b0f0..e953ea4 100644 --- a/dungeon/src/pos.rs +++ b/dungeon/src/pos.rs @@ -150,3 +150,9 @@ impl Pos { (0..MAP_SIZE).flat_map(|y| (0..MAP_SIZE).filter_map(move |x| Self::new(x, y))) } } +impl Default for Pos { + fn default() -> Self { + const DEFAULT: Pos = Pos::new_const::<0, 0>(); + DEFAULT + } +} |