-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3bf66e7
commit 0b9de85
Showing
4 changed files
with
50 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
use bevy::prelude::*; | ||
|
||
use crate::states::GameState; | ||
|
||
pub struct PausePlugin; | ||
|
||
impl Plugin for PausePlugin { | ||
fn build(&self, app: &mut App) { | ||
app.add_systems(PostUpdate, pause); | ||
} | ||
} | ||
|
||
fn pause( | ||
current_state: Res<State<GameState>>, | ||
mut game_state: ResMut<NextState<GameState>>, | ||
mut keyboard_input: ResMut<Input<KeyCode>>, | ||
) { | ||
if keyboard_input.just_pressed(KeyCode::Escape) { | ||
match current_state.get() { | ||
GameState::Game => { | ||
game_state.set(GameState::Pause); | ||
} | ||
GameState::Pause => { | ||
game_state.set(GameState::Game); | ||
} | ||
_ => { | ||
return; | ||
} | ||
} | ||
keyboard_input.reset(KeyCode::Escape); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,6 @@ use bevy::ecs::schedule::States; | |
pub enum GameState { | ||
#[default] | ||
Splash, | ||
// Pause, | ||
Pause, | ||
Game, | ||
} |