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) { 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>, score: Res, level: Res, ) { 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}"); } }