game states cleanup
This commit is contained in:
@@ -3,7 +3,6 @@ use bevy::prelude::*;
|
|||||||
use crate::game_state::GameState;
|
use crate::game_state::GameState;
|
||||||
use crate::player::Player;
|
use crate::player::Player;
|
||||||
use crate::player::move_player;
|
use crate::player::move_player;
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct MainCamera;
|
pub struct MainCamera;
|
||||||
|
|
||||||
|
|||||||
+4
-2
@@ -1,12 +1,14 @@
|
|||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
|
|
||||||
use crate::game_state::GameState;
|
use crate::{camera::MainCamera, game_state::GameState};
|
||||||
|
|
||||||
// To delete game over's components
|
// To delete game over's components
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct GameOver;
|
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((
|
commands.spawn((
|
||||||
GameOver,
|
GameOver,
|
||||||
Node {
|
Node {
|
||||||
|
|||||||
+3
-7
@@ -35,14 +35,10 @@ fn spawn_depth_text(mut commands: Commands) {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update depth score text
|
// Update depth score texts
|
||||||
fn update_depth_text(
|
fn update_depth_text(depth: Res<Depth>, texts: Query<&mut Text, With<DepthText>>) {
|
||||||
mut commands: Commands,
|
|
||||||
depth: Res<Depth>,
|
|
||||||
texts: Query<&mut Text, With<DepthText>>,
|
|
||||||
) {
|
|
||||||
for mut text in texts {
|
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