diff --git a/src/lib.rs b/src/lib.rs index 006ece5..8567a2b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -47,7 +47,7 @@ impl Plugin for AsteroidPlugin { .add_systems(Startup, spawn_camera) .add_systems( OnEnter(GameState::Playing), - (objects::spawn_player, spawn_ui), + (objects::spawn_player, widgets::spawn_ui), ) .add_systems( FixedUpdate, @@ -186,10 +186,3 @@ fn input_ship_shoot( )); } } - -fn spawn_ui(mut commands: Commands, score: Res, lives: Res) { - commands.spawn(( - Text::new(format!("Score: {score:?} | Lives: {lives:?}")), - TextFont::from_font_size(25.0), - )); -} diff --git a/src/widgets.rs b/src/widgets.rs index 11733be..c9b898e 100644 --- a/src/widgets.rs +++ b/src/widgets.rs @@ -1,10 +1,20 @@ -use crate::GameState; +use crate::{ + GameState, + resources::{Lives, Score}, +}; use bevy::{ color::palettes::css::{BLACK, GREEN, LIGHT_BLUE, RED}, prelude::*, }; +pub fn spawn_ui(mut commands: Commands, score: Res, lives: Res) { + commands.spawn(( + Text::new(format!("Score: {score:?} | Lives: {lives:?}")), + TextFont::from_font_size(25.0), + )); +} + pub fn preparation_widget_plugin(app: &mut App) { app.add_systems(OnEnter(GameState::GetReady), spawn_get_ready) .add_systems(OnExit(GameState::GetReady), despawn_get_ready)