diff --git a/Cargo.toml b/Cargo.toml index edd172e..b04fb2c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "flappyspace" -version = "1.1.0" +version = "1.1.1" edition = "2021" description = "A small game about a little UFO dodging asteroids built in Bevy" readme = "README.md" diff --git a/src/about.rs b/src/about.rs index 02047cd..0918d59 100644 --- a/src/about.rs +++ b/src/about.rs @@ -46,7 +46,7 @@ fn spawn_about_text(mut commands: Commands, assets: Res) { commands.spawn(( text_from_str( &assets, - "Press Enter to exit", + "Press X to exit", INPUT_HINT_FONT_SIZE, ABOUT_TEXT_COLOR, INPUT_HINT_ONE_Y @@ -54,12 +54,12 @@ fn spawn_about_text(mut commands: Commands, assets: Res) { )); } -/// Checks for user input (Enter) to launch main menu +/// Checks for user input (spacebar) to launch main menu fn about_input( mut game_state: ResMut>, key: Res> ) { - if key.just_pressed(KeyCode::Return) { + if key.just_pressed(KeyCode::X) { game_state.set(GameState::Menu); } } diff --git a/src/consts.rs b/src/consts.rs index fbf3130..093e673 100644 --- a/src/consts.rs +++ b/src/consts.rs @@ -68,7 +68,7 @@ pub const ABOUT_TEXT: &str = "Flappy Space Built with Bevy Engine -v1.1.0 GPL-3.0 License"; +v1.1.1 GPL-3.0 License"; /// Font size of content in About screen pub const ABOUT_TEXT_FONT_SIZE: f32 = 30.; diff --git a/src/crashed.rs b/src/crashed.rs index 968accf..80c5401 100644 --- a/src/crashed.rs +++ b/src/crashed.rs @@ -1,5 +1,6 @@ use bevy::prelude::*; use flappyspace::*; +use crate::game::*; /// Custom game plugin for all things on the Game Over screen pub struct CrashedPlugin; @@ -13,20 +14,26 @@ impl Plugin for CrashedPlugin { app .add_systems( OnEnter(GameState::Crashed), - (spawn_crashed_text, spawn_highscore) + (spawn_crashed_text, spawn_highscore, move_ship_y) ) .add_systems( Update, - (lobby_input, rotate_text).run_if(in_state(GameState::Crashed)) + (lobby_input, rotate_text, move_rocks).run_if(in_state(GameState::Crashed)) ) .add_systems(OnExit(GameState::Crashed), ( cleanup::, cleanup::, - cleanup:: + cleanup::, + spawn_ship )); } } +/// Marks the ship as Rock so that it moves with them after the crash +fn move_ship_y(mut commands: Commands, query: Query>) { + commands.entity(query.single()).insert(Rock); +} + /// Spawns text on Game Over screen: heading, two input hints fn spawn_crashed_text(mut commands: Commands, assets: Res) { commands.spawn(( @@ -41,7 +48,7 @@ fn spawn_crashed_text(mut commands: Commands, assets: Res) { commands.spawn(( text_from_str( &assets, - "Press Enter to restart", + "Press X to restart", INPUT_HINT_FONT_SIZE, Color::RED, INPUT_HINT_UPPER_Y diff --git a/src/game.rs b/src/game.rs index 31b5a5e..17ea141 100644 --- a/src/game.rs +++ b/src/game.rs @@ -26,6 +26,22 @@ impl Plugin for GamePlugin { } } +/// Moves every present Rock using ROCK_VELOCITY, despawns it if ROCK_DESPAWN_X +/// coordinate is crossed +pub fn move_rocks( + mut commands: Commands, + mut rock_query: Query<(Entity, &mut Transform), With>, + time: Res