Move HUD spawning system into widgets
It actually needs to be completely replaced. When that finally happens, the new bits will live here.
This commit is contained in:
@@ -47,7 +47,7 @@ impl Plugin for AsteroidPlugin {
|
|||||||
.add_systems(Startup, spawn_camera)
|
.add_systems(Startup, spawn_camera)
|
||||||
.add_systems(
|
.add_systems(
|
||||||
OnEnter(GameState::Playing),
|
OnEnter(GameState::Playing),
|
||||||
(objects::spawn_player, spawn_ui),
|
(objects::spawn_player, widgets::spawn_ui),
|
||||||
)
|
)
|
||||||
.add_systems(
|
.add_systems(
|
||||||
FixedUpdate,
|
FixedUpdate,
|
||||||
@@ -186,10 +186,3 @@ fn input_ship_shoot(
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn spawn_ui(mut commands: Commands, score: Res<Score>, lives: Res<Lives>) {
|
|
||||||
commands.spawn((
|
|
||||||
Text::new(format!("Score: {score:?} | Lives: {lives:?}")),
|
|
||||||
TextFont::from_font_size(25.0),
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,10 +1,20 @@
|
|||||||
use crate::GameState;
|
use crate::{
|
||||||
|
GameState,
|
||||||
|
resources::{Lives, Score},
|
||||||
|
};
|
||||||
|
|
||||||
use bevy::{
|
use bevy::{
|
||||||
color::palettes::css::{BLACK, GREEN, LIGHT_BLUE, RED},
|
color::palettes::css::{BLACK, GREEN, LIGHT_BLUE, RED},
|
||||||
prelude::*,
|
prelude::*,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
pub fn spawn_ui(mut commands: Commands, score: Res<Score>, lives: Res<Lives>) {
|
||||||
|
commands.spawn((
|
||||||
|
Text::new(format!("Score: {score:?} | Lives: {lives:?}")),
|
||||||
|
TextFont::from_font_size(25.0),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
pub fn preparation_widget_plugin(app: &mut App) {
|
pub fn preparation_widget_plugin(app: &mut App) {
|
||||||
app.add_systems(OnEnter(GameState::GetReady), spawn_get_ready)
|
app.add_systems(OnEnter(GameState::GetReady), spawn_get_ready)
|
||||||
.add_systems(OnExit(GameState::GetReady), despawn_get_ready)
|
.add_systems(OnExit(GameState::GetReady), despawn_get_ready)
|
||||||
|
|||||||
Reference in New Issue
Block a user