diff --git a/src/components.rs b/src/components.rs index e38611d..08450ed 100644 --- a/src/components.rs +++ b/src/components.rs @@ -1,7 +1,6 @@ pub mod character; pub mod collect_coin; pub mod damage; -pub mod dead_screen_plugin; pub mod health; pub mod jump; pub mod kills_player; @@ -14,7 +13,6 @@ impl bevy::prelude::Plugin for ComponentsPlugin { app.add_plugins(( character::CharacterPlugin, kills_player::KillsPlayerPlugin, - dead_screen_plugin::DeadScreenPlugin, npc_movement::NpcMovementPlugin, player_win::PlayerWinPlugin, damage::DamagePlugin, diff --git a/src/components/dead_screen_plugin.rs b/src/components/dead_screen_plugin.rs deleted file mode 100644 index 17989cd..0000000 --- a/src/components/dead_screen_plugin.rs +++ /dev/null @@ -1,14 +0,0 @@ -use bevy::prelude::*; - -use crate::state::GameState; - -pub struct DeadScreenPlugin; -impl Plugin for DeadScreenPlugin { - fn build(&self, app: &mut App) { - app.add_systems(OnEnter(GameState::Dead), on_dead); - } -} - -fn on_dead() { - panic!("Player died. Sorry!") -} diff --git a/src/dead_screen.rs b/src/dead_screen.rs new file mode 100644 index 0000000..401e61e --- /dev/null +++ b/src/dead_screen.rs @@ -0,0 +1,41 @@ +use bevy::prelude::*; + +use crate::state::GameState; + +pub struct DeadScreenPlugin; +impl Plugin for DeadScreenPlugin { + fn build(&self, app: &mut App) { + app.add_systems(OnEnter(GameState::Dead), setup); + } +} + +fn setup(mut commands: Commands) { + commands + .spawn(NodeBundle { + style: Style { + width: Val::Percent(100.0), + height: Val::Percent(100.0), + ..default() + }, + background_color: BackgroundColor(Color::Hsla { + hue: 0.0, + saturation: 0.0, + lightness: 0.0, + alpha: 0.5, + }), + ..default() + }) + .with_children(|parent| { + parent.spawn(TextBundle { + text: Text::from_section( + "You died. Sorry!", + TextStyle { + font_size: 100.0, + color: Color::WHITE, + ..default() + }, + ), + ..default() + }); + }); +} diff --git a/src/lib.rs b/src/lib.rs index c78c0db..038c494 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -7,6 +7,7 @@ use crate::state::GameState; mod bundles; mod camera; mod components; +mod dead_screen; mod level; mod start_screen; mod state; @@ -38,6 +39,7 @@ pub fn start_app() { InputManagerPlugin::::default(), camera::CameraPlugin, start_screen::StartScreenPlugin, + dead_screen::DeadScreenPlugin, bundles::player::PlayerPlugin, level::LevelPlugin, components::ComponentsPlugin,