summaryrefslogtreecommitdiff
path: root/game/src/main.rs
blob: a44f3172d006024d18510572f49f72f232bfaf4b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#[cfg(any(target_os = "linux", target_os = "macos", target_os = "windows"))]
mod arch {
	use argh::FromArgs;
	use game::Game;
	use graphics::WindowBuilder;

	/// Play a dungeon crawl game
	#[derive(FromArgs)]
	struct Args {
		/// enable vsync
		#[argh(switch)]
		vsync: bool,
		/// enable verbose logging
		#[argh(switch, short = 'v')]
		verbose: bool,
		/// set the map seed
		#[argh(option)]
		seed: Option<u64>,
	}

	pub fn main() -> graphics::Result<()> {
		// Parse arguments
		let args: Args = argh::from_env();
		// Load the window
		let window = WindowBuilder::new()
			.vsync(args.vsync)
			.verbose(args.verbose)
			.build()?;
		Game::new(window, args.seed).run();
		Ok(())
	}
}

#[cfg(not(any(target_os = "linux", target_os = "macos", target_os = "windows")))]
mod arch {
	use game::Game;
	use graphics::WindowBuilder;

	pub fn main() -> graphics::Result<()> {
		// Load the window
		let window = WindowBuilder::new().build()?;
		Game::new(window, None).run();
		Ok(())
	}
}

pub fn main() -> graphics::Result<()> {
	arch::main()
}