Simplify main function by extracting game state setup code
This commit is contained in:
parent
0f3903e456
commit
64cc39eba1
18
src/main.rs
18
src/main.rs
@ -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())
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user