Skip to content

Commit

Permalink
v1.0.1: Tweaked gravity, changed scoreboard behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
hiimsergey authored Nov 3, 2023
1 parent 2ba85c6 commit 3ff1074
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "flappyspace"
version = "1.0.0"
version = "1.0.1"
edition = "2021"
description = "A small game about a little UFO dodging asteroids built in Bevy"
readme = "README.md"
Expand Down
4 changes: 2 additions & 2 deletions src/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ pub const TOP_BOUND: f32 = 425.;
pub const BOTTOM_BOUND: f32 = -TOP_BOUND;

/// Number that the ship's velocity is being decreased by every frame
pub const GRAVITY: f32 = 40.;
pub const GRAVITY: f32 = 35.;

/// Number that the ship's velocity gets set to after a jump
pub const JUMP_VELOCITY: f32 = 500.;
pub const JUMP_VELOCITY: f32 = 450.;



Expand Down
7 changes: 5 additions & 2 deletions src/game.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ fn update_ship(
ship.velocity -= GRAVITY;

// Rotates ship according to velocity
// The factor 0.0005 is chosen randomly but looks convenient
transform.rotation = Quat::from_rotation_z(0.0005 * ship.velocity);
// The factor 0.00075 is chosen randomly but looks convenient
transform.rotation = Quat::from_rotation_z(0.00075 * ship.velocity);

// Checks for input (Space) and applies increased velocity
if key.just_pressed(KeyCode::Space) {
Expand All @@ -153,6 +153,7 @@ fn update_ship(
fn check_collisions(
mut commands: Commands,
mut ship_query: Query<(&mut TextureAtlasSprite, &Transform), With<Ship>>,
mut score_text_query: Query<&mut Text, With<Scoreboard>>,
mut game_state: ResMut<NextState<GameState>>,
assets: Res<AssetServer>,
rock_query: Query<&Transform, With<Rock>>
Expand All @@ -178,6 +179,8 @@ fn check_collisions(
).is_some() {
// Changes ship sprite to broken ship
sprite.index = 0;
// Changes color of the scoreboard to make it more visible
score_text_query.single_mut().sections[0].style.color = Color::RED;
play_sound(&mut commands, &assets, "crash");
game_state.set(GameState::Crashed);
}
Expand Down

0 comments on commit 3ff1074

Please sign in to comment.