game states cleanup

This commit is contained in:
2026-09-19 11:53:49 +02:00
parent 452d39dd45
commit 832d4ba847
3 changed files with 7 additions and 10 deletions
-1
View File
@@ -3,7 +3,6 @@ use bevy::prelude::*;
use crate::game_state::GameState;
use crate::player::Player;
use crate::player::move_player;
#[derive(Component)]
pub struct MainCamera;
+4 -2
View File
@@ -1,12 +1,14 @@
use bevy::prelude::*;
use crate::game_state::GameState;
use crate::{camera::MainCamera, game_state::GameState};
// To delete game over's components
#[derive(Component)]
pub struct GameOver;
fn game_over(mut commands: Commands) {
fn game_over(mut commands: Commands, mut main_camera: Single<&mut Camera, With<MainCamera>>) {
main_camera.is_active = true;
commands.spawn((
GameOver,
Node {
+3 -7
View File
@@ -35,14 +35,10 @@ fn spawn_depth_text(mut commands: Commands) {
));
}
// Update depth score text
fn update_depth_text(
mut commands: Commands,
depth: Res<Depth>,
texts: Query<&mut Text, With<DepthText>>,
) {
// Update depth score texts
fn update_depth_text(depth: Res<Depth>, texts: Query<&mut Text, With<DepthText>>) {
for mut text in texts {
text.0 = format!("Score: {}", depth.0);
text.0 = format!("Score: {}", (depth.0 / 100.0).floor());
}
}