diff options
| author | Freya Murphy <freya@freyacat.org> | 2025-11-13 10:20:26 -0500 |
|---|---|---|
| committer | Freya Murphy <freya@freyacat.org> | 2025-11-13 10:20:26 -0500 |
| commit | ed797498d9acee8a55aae3b7b75d72ed293e99a7 (patch) | |
| tree | cd1dcd9f6849b2c5fce54a57d93a8614ef1a7af8 | |
| parent | bsp: why was this unsafe? (diff) | |
| download | DungeonCrawl-ed797498d9acee8a55aae3b7b75d72ed293e99a7.tar.gz DungeonCrawl-ed797498d9acee8a55aae3b7b75d72ed293e99a7.tar.bz2 DungeonCrawl-ed797498d9acee8a55aae3b7b75d72ed293e99a7.zip | |
game: add option to pass in the game seed
| -rw-r--r-- | game/src/main.rs | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/game/src/main.rs b/game/src/main.rs index 569d08a..4d67a52 100644 --- a/game/src/main.rs +++ b/game/src/main.rs @@ -10,9 +10,11 @@ struct Game { } impl Game { - fn new(window: Window) -> Self { - // Initial game state - let dungeon = Dungeon::random(); + fn new(window: Window, seed: Option<u64>) -> Self { + let dungeon = match seed { + Some(s) => Dungeon::new(s), + None => Dungeon::random(), + }; Self { window, dungeon, @@ -86,6 +88,9 @@ struct Args { /// enable verbose logging #[argh(switch, short = 'v')] verbose: bool, + /// set the map seed + #[argh(option)] + seed: Option<u64>, } fn main() -> Result<()> { @@ -96,6 +101,6 @@ fn main() -> Result<()> { .vsync(args.vsync) .verbose(args.verbose) .build()?; - Game::new(window).run(); + Game::new(window, args.seed).run(); Ok(()) } |