WIP2
This commit is contained in:
21
src/level.rs
Normal file
21
src/level.rs
Normal file
@@ -0,0 +1,21 @@
|
||||
use bevy::prelude::*;
|
||||
|
||||
// #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, Default, States)]
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, Default)]
|
||||
pub enum LevelState {
|
||||
#[default]
|
||||
Begin,
|
||||
InGame,
|
||||
End,
|
||||
}
|
||||
|
||||
#[derive(Resource)]
|
||||
struct Level(u32);
|
||||
|
||||
pub(super) struct LevelPlugin;
|
||||
|
||||
impl Plugin for LevelPlugin {
|
||||
fn build(&self, app: &mut App) {
|
||||
// app.add_state::<LevelState>();
|
||||
}
|
||||
}
|
||||
1
src/ui/menu.rs
Normal file
1
src/ui/menu.rs
Normal file
@@ -0,0 +1 @@
|
||||
use bevy::prelude::*;
|
||||
61
src/ui/status.rs
Normal file
61
src/ui/status.rs
Normal file
@@ -0,0 +1,61 @@
|
||||
use crate::{Level, Score};
|
||||
use bevy::prelude::*;
|
||||
|
||||
#[derive(Component)]
|
||||
pub(super) struct StatusText;
|
||||
|
||||
pub(super) fn spawn_status_text(mut commands: Commands, asset_server: Res<AssetServer>) {
|
||||
let font = asset_server.load("fonts/Audiowide-Regular.ttf");
|
||||
|
||||
commands.spawn((
|
||||
StatusText,
|
||||
TextBundle::from_sections([
|
||||
TextSection::new(
|
||||
"Level: ",
|
||||
TextStyle {
|
||||
font: font.clone(),
|
||||
font_size: 32.0,
|
||||
color: Color::WHITE,
|
||||
},
|
||||
),
|
||||
TextSection::from_style(TextStyle {
|
||||
font: font.clone(),
|
||||
font_size: 32.0,
|
||||
color: Color::WHITE,
|
||||
}),
|
||||
TextSection::new(
|
||||
" Score: ",
|
||||
TextStyle {
|
||||
font: font.clone(),
|
||||
font_size: 32.0,
|
||||
color: Color::WHITE,
|
||||
},
|
||||
),
|
||||
TextSection::from_style(TextStyle {
|
||||
font,
|
||||
font_size: 32.0,
|
||||
color: Color::WHITE,
|
||||
}),
|
||||
])
|
||||
.with_style(Style {
|
||||
position_type: PositionType::Absolute,
|
||||
left: Val::Px(10.0),
|
||||
bottom: Val::Px(10.0),
|
||||
..Default::default()
|
||||
}),
|
||||
));
|
||||
}
|
||||
|
||||
pub(super) fn update_status_text(
|
||||
mut query: Query<&mut Text, With<StatusText>>,
|
||||
score: Res<Score>,
|
||||
level: Res<Level>,
|
||||
) {
|
||||
let score = score.0;
|
||||
let level = level.0;
|
||||
|
||||
for mut text in query.iter_mut() {
|
||||
text.sections[1].value = format!("{level}");
|
||||
text.sections[3].value = format!("{score}");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user