UI start, wave text
All checks were successful
Build Bevy Game (Linux + Windows) / build-windows (push) Successful in 18m17s
Build Bevy Game (Linux + Windows) / build-linux (push) Successful in 18m37s

This commit is contained in:
Crizomb 2026-01-04 18:30:09 +01:00
parent dece3a352f
commit e6da44779e
4 changed files with 35 additions and 1 deletions

View file

@ -192,7 +192,7 @@ fn spawn_wave_ennemy(
collectable_spawn(&mut commands, &asset_server, *collectable_type, *collectable_pos); collectable_spawn(&mut commands, &asset_server, *collectable_type, *collectable_pos);
} }
bubble_wave.current_wave += 1; 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<Kirby>>) { fn heal_kirby(query: Query<&mut Life, With<Kirby>>) {

View file

@ -1,2 +1,3 @@
pub mod animation; pub mod animation;
pub mod camera; pub mod camera;
pub mod ui;

31
src/juice/ui.rs Normal file
View file

@ -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<BubbleWaves>, text_single: Single<&mut Text, With<WaveText>>) {
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);
}
}

View file

@ -23,6 +23,7 @@ use juice::camera::MyCameraPlugin;
use crate::core::game_state::GameEventsPlugin; use crate::core::game_state::GameEventsPlugin;
use crate::core::wave::WavePlugin; use crate::core::wave::WavePlugin;
use crate::juice::ui::UIPlugin;
fn main() { fn main() {
App::new() App::new()
@ -43,6 +44,7 @@ fn main() {
.add_plugins(MyCameraPlugin) .add_plugins(MyCameraPlugin)
.add_plugins(CollectablePlugin) .add_plugins(CollectablePlugin)
.add_plugins(WavePlugin) .add_plugins(WavePlugin)
.add_plugins(UIPlugin)
.insert_resource(Time::<Fixed>::from_seconds(1.0 / 60.0)) .insert_resource(Time::<Fixed>::from_seconds(1.0 / 60.0))
.insert_resource(MapBounds { min: -Vec2::ONE * MAP_WIDTH as f32, max: Vec2::ONE * MAP_WIDTH as f32 }) .insert_resource(MapBounds { min: -Vec2::ONE * MAP_WIDTH as f32, max: Vec2::ONE * MAP_WIDTH as f32 })
.add_systems(Update, animate_sprite) .add_systems(Update, animate_sprite)