feat: add restart from game over with R key

This commit is contained in:
Harald Hoyer 2026-05-04 22:15:16 +02:00
parent e484c09f14
commit 3c226b3f78
2 changed files with 10 additions and 0 deletions

View file

@ -19,7 +19,9 @@ use resources::{ // Added StageConfigurations
use game_state::{
cleanup_game_entities, cleanup_game_over_ui, setup_game_over_ui, AppState,
setup_start_menu_ui, cleanup_start_menu_ui, start_menu_button_system,
handle_restart_input, restart_game_system,
};
use resources::RestartPressed;
use player::{
check_player_enemy_collisions, manage_invincibility, move_player, player_shoot,
respawn_player, handle_captured_player,
@ -74,6 +76,7 @@ fn main() {
timer: Timer::new(Duration::from_secs_f32(3.0), TimerMode::Once),
})
.insert_resource(StageConfigurations::default()) // Use default stages for now
.insert_resource(RestartPressed::default())
// Add startup systems
.add_systems(Startup, setup)
// Core game systems
@ -117,6 +120,8 @@ fn main() {
.add_systems(OnExit(AppState::StartMenu), cleanup_start_menu_ui)
.add_systems(Update, start_menu_button_system.run_if(in_state(AppState::StartMenu)))
.add_systems(OnEnter(AppState::GameOver), setup_game_over_ui)
.add_systems(Update, handle_restart_input.run_if(in_state(AppState::GameOver)))
.add_systems(Update, restart_game_system.run_if(in_state(AppState::GameOver)))
.add_systems(OnExit(AppState::Playing), cleanup_game_entities)
.add_systems(OnExit(AppState::GameOver), cleanup_game_over_ui)
.run();

View file

@ -132,3 +132,8 @@ pub struct FormationState {
pub struct AttackDiveTimer {
pub timer: Timer,
}
#[derive(Resource, Default)]
pub struct RestartPressed {
pub pressed: bool,
}