diff --git a/src/core/wave.rs b/src/core/wave.rs index 9f406ef..d6725d7 100644 --- a/src/core/wave.rs +++ b/src/core/wave.rs @@ -192,7 +192,7 @@ fn spawn_wave_ennemy( collectable_spawn(&mut commands, &asset_server, *collectable_type, *collectable_pos); } bubble_wave.current_wave += 1; - lock.0 = false; // Release lock, ennemy wave is spawnned + lock.0 = false; // Release lock, ennemy wave is spawned } fn heal_kirby(query: Query<&mut Life, With>) { diff --git a/src/juice/mod.rs b/src/juice/mod.rs index 0bb2e4c..16f9486 100644 --- a/src/juice/mod.rs +++ b/src/juice/mod.rs @@ -1,2 +1,3 @@ pub mod animation; pub mod camera; +pub mod ui; diff --git a/src/juice/ui.rs b/src/juice/ui.rs new file mode 100644 index 0000000..5436a81 --- /dev/null +++ b/src/juice/ui.rs @@ -0,0 +1,31 @@ +use crate::core::{game_state::DispawnOnGameOver, wave::BubbleWaves}; +use bevy::prelude::*; + +#[derive(Component)] +struct WaveText; + +fn setup_ui(mut commands: Commands) { + commands.spawn(( + Text::new("Waves : "), + TextFont { font_size: 32.0, ..default() }, + TextLayout::new_with_justify(Justify::Left), + WaveText, + )); +} + +fn update_score_text(bubble_wave: Res, text_single: Single<&mut Text, With>) { + if !bubble_wave.is_changed() { + return; + } + let mut text = text_single.into_inner(); + **text = format!("Wave : {}", bubble_wave.current_wave); + println!("ui text {:?}", text); +} + +pub struct UIPlugin; + +impl Plugin for UIPlugin { + fn build(&self, app: &mut App) { + app.add_systems(Startup, setup_ui).add_systems(Update, update_score_text); + } +} diff --git a/src/main.rs b/src/main.rs index b071cc6..b66c1b3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -23,6 +23,7 @@ use juice::camera::MyCameraPlugin; use crate::core::game_state::GameEventsPlugin; use crate::core::wave::WavePlugin; +use crate::juice::ui::UIPlugin; fn main() { App::new() @@ -43,6 +44,7 @@ fn main() { .add_plugins(MyCameraPlugin) .add_plugins(CollectablePlugin) .add_plugins(WavePlugin) + .add_plugins(UIPlugin) .insert_resource(Time::::from_seconds(1.0 / 60.0)) .insert_resource(MapBounds { min: -Vec2::ONE * MAP_WIDTH as f32, max: Vec2::ONE * MAP_WIDTH as f32 }) .add_systems(Update, animate_sprite)