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

View File

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