game states cleanup
This commit is contained in:
@@ -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
@@ -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
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user