UI start, wave text
This commit is contained in:
parent
dece3a352f
commit
e6da44779e
4 changed files with 35 additions and 1 deletions
|
|
@ -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>>) {
|
||||||
|
|
|
||||||
|
|
@ -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
31
src/juice/ui.rs
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -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)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue