1
0
Fork 0

Simplify main function by extracting game state setup code

This commit is contained in:
Timothy Warren 2022-01-20 15:58:08 -05:00
parent 0f3903e456
commit 64cc39eba1
1 changed files with 11 additions and 7 deletions

View File

@ -50,12 +50,7 @@ macro_rules! register {
}
}
fn main() -> ::rltk::BError {
let context = ::rltk::RltkBuilder::simple(80, 60)
.unwrap()
.with_title("Roguelike Tutorial")
.build()?;
fn init_state() -> State {
let mut state = State::new();
register!(
@ -144,5 +139,14 @@ fn main() -> ::rltk::BError {
state.generate_world_map(1, 0);
::rltk::main_loop(context, state)
state
}
fn main() -> ::rltk::BError {
let context = ::rltk::RltkBuilder::simple(80, 60)
.unwrap()
.with_title("Roguelike Tutorial")
.build()?;
::rltk::main_loop(context, init_state())
}