amethyst / rustrogueliketutorial

Roguelike Tutorial in Rust - using RLTK
MIT License
905 stars 156 forks source link

C11. "Begin New Game" does not reset game state #126

Open smokku opened 4 years ago

smokku commented 4 years ago

Chapter 11:

Player returns to existing game state, instead of "New Game" state.

Zij-IT commented 3 years ago

Hey all!

If someone is just looking for a quick and snappy solution to this, just change the follow line from:

//main.rs
fn tick(&mut self, ctx: &mut Rltk) {
    //snip
    gui::MainMenuSelection::NewGame => next_state = RunState::PreRun,
}

to:

//main.rs
fn tick(&mut self, ctx: &mut Rltk) {
    //snip
    gui::MainMenuSelection::NewGame => {
        self.game_over_cleanup();
        next_state = RunState::PreRun;
    }
}

The source code for game_over_cleanup(); can be found in Chapter 14!