Skip to content

Commit

Permalink
refactor: Disable trails when min move speed
Browse files Browse the repository at this point in the history
Also tweaked some values.
  • Loading branch information
PraxTube committed Nov 2, 2023
1 parent 8302b5b commit 7b2b5d0
Show file tree
Hide file tree
Showing 12 changed files with 42 additions and 21 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
**/all_sounds
/target
*/tileset
/logs
/footage
.env
turn-credentials.toml
Binary file modified assets/sounds/bullet_shot.ogg
Binary file not shown.
2 changes: 1 addition & 1 deletion src/player/dodge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use crate::{input::dodge, misc::utils::quat_from_vec3, network::GgrsConfig};

use super::Player;

const DODGE_COOLDOWN: f32 = 2.0;
const DODGE_COOLDOWN: f32 = 2.5;
const DODGE_TIME: f32 = 0.5;

const DODGE_REFRESH_TIME: f32 = 0.50;
Expand Down
1 change: 1 addition & 0 deletions src/player/effect/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ impl Plugin for EffectPlugin {
damage::add_damage_camera_shake,
bullet::spawn_collision_effect,
trail::disable_trails,
trail::toggle_plane_trail_visibilities,
trail::despawn_trails,
)
.chain()
Expand Down
21 changes: 19 additions & 2 deletions src/player/effect/trail.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ use bevy::prelude::*;
use bevy_ggrs::AddRollbackCommandExtension;
use bevy_hanabi::prelude::*;

use crate::network::ggrs_config::GGRS_FPS;
use crate::{
network::ggrs_config::GGRS_FPS,
player::{Player, MIN_SPEED},
};

const LEFT_TRAIL_OFFSET: Vec3 = Vec3::new(0.0, 30.0, -1.0);
const RIGHT_TRAIL_OFFSET: Vec3 = Vec3::new(0.0, -30.0, -1.0);
Expand Down Expand Up @@ -108,7 +111,7 @@ pub fn disable_trails(
if parents.get(parent.get()).is_ok() {
continue;
}
if !trail.is_active() {
if !kill_timer.0.paused() {
continue;
}

Expand All @@ -130,3 +133,17 @@ pub fn despawn_trails(
}
}
}

pub fn toggle_plane_trail_visibilities(
mut trails: Query<(&Parent, &mut EffectSpawner), With<Trail>>,
players: Query<&Player>,
) {
for (parent, mut trail) in &mut trails {
let player = match players.get(parent.get()) {
Ok(player) => player,
Err(_) => continue,
};

trail.set_active(player.current_speed != MIN_SPEED);
}
}
10 changes: 5 additions & 5 deletions src/player/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ use bevy::prelude::*;
use bevy_ggrs::*;

use crate::input;
use crate::network::ggrs_config::PLAYER_COUNT;
use crate::network::ggrs_config::{GGRS_FPS, PLAYER_COUNT};
use crate::network::GgrsConfig;
use crate::world::Rematch;
use crate::RollbackState;

// Movement
pub const MIN_SPEED: f32 = 200.0 / 60.0;
pub const DELTA_SPEED: f32 = 75.0 / 60.0 / 100.0;
pub const DELTA_STEERING: f32 = 3.5 / 60.0;
pub const MIN_SPEED: f32 = 200.0 / GGRS_FPS as f32;
pub const DELTA_SPEED: f32 = 3.0 / GGRS_FPS as f32;
pub const DELTA_STEERING: f32 = 3.5 / GGRS_FPS as f32;
// Collision
pub const PLAYER_RADIUS: f32 = 24.0;
// Color
Expand Down Expand Up @@ -47,7 +47,7 @@ impl Default for PlayerStats {
Self {
max_speed: 400.0 / 60.0,
max_health: 2000,
bullet_damage: 30,
bullet_damage: 40,
rocket_reload_time: 2.5,
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/player/movement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pub fn accelerate_players(inputs: Res<PlayerInputs<GgrsConfig>>, mut players: Qu
}

let acceleration = if accelerate_direction > 0.0 {
DELTA_SPEED * 3.0
DELTA_SPEED
} else {
-DELTA_SPEED
};
Expand Down
13 changes: 7 additions & 6 deletions src/player/shooting/bullet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ use crate::GameAssets;

use super::reloading::OVERHEAT;

pub const BULLET_RADIUS: f32 = 1.0;
const BULLET_MOVE_SPEED: f32 = 350.0 / 60.0;
const BULLET_RELOAD_TIME: f32 = 0.1;
const FIRE_HEAT: u32 = 40;
pub const BULLET_RADIUS: f32 = 3.0;
pub const BULLET_SPRITE_SIZE: Vec2 = Vec2::new(20.0, 7.0);
const BULLET_MOVE_SPEED: f32 = 450.0 / 60.0;
const BULLET_RELOAD_TIME: f32 = 0.25;
const FIRE_HEAT: u32 = 80;

const LEFT_WING_BULLET_SPAWN: Vec3 = Vec3::new(20.0, 10.0, 0.0);
const RIGHT_WING_BULLET_SPAWN: Vec3 = Vec3::new(20.0, -10.0, 0.0);
Expand Down Expand Up @@ -116,15 +117,15 @@ fn spawn_bullet(
transform,
texture: assets.bullet.clone(),
sprite: Sprite {
custom_size: Some(Vec2::new(14.0, 5.0)),
custom_size: Some(BULLET_SPRITE_SIZE),
..default()
},
..default()
},
))
.add_rollback()
.id();
let playback_rate = 1.0 + (player.heat as f64 / OVERHEAT as f64).powi(3);
let playback_rate = 1.0 + (player.heat as f64 / OVERHEAT as f64).powi(3) * 0.5;
commands
.spawn(RollbackSound {
clip: assets.bullet_shot.clone(),
Expand Down
4 changes: 2 additions & 2 deletions src/player/shooting/bullet_casing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use rand::{self, Rng};

use bevy::prelude::*;

use super::bullet::BulletFired;
use super::bullet::{BulletFired, BULLET_SPRITE_SIZE};
use crate::{misc::DeadSprite, world::CollisionEntity, GameAssets};

const TRANSLATION_STRENGTH: f32 = 300.0;
Expand Down Expand Up @@ -49,7 +49,7 @@ pub fn spawn_bullet_casings(
transform: Transform::from_translation(ev.position - Vec3::new(0.0, 0.0, 10.0))
.with_rotation(Quat::from_rotation_z(rng.gen_range(-3.0..3.0))),
sprite: Sprite {
custom_size: Some(Vec2::new(10.0, 5.0)),
custom_size: Some(BULLET_SPRITE_SIZE),
color: Color::rgb(0.75, 0.6, 0.2),
..default()
},
Expand Down
2 changes: 1 addition & 1 deletion src/player/shooting/rocket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use super::rocket_explosion::spawn_rocket_explosion;
const ROCKET_RADIUS: f32 = 1.5;
const ROCKET_MOVE_SPEED: f32 = 700.0 / 60.0;
const ROCKET_START_TIME: f32 = 0.5;
const ROCKET_PUSH_STRENGTH: f32 = 25.0;
const ROCKET_PUSH_STRENGTH: f32 = 20.0;

const LEFT_WING_ROCKET_OFFSET: Vec3 = Vec3::new(8.0, 22.0, -1.0);
const RIGHT_WING_ROCKET_OFFSET: Vec3 = Vec3::new(8.0, -22.0, -1.0);
Expand Down
3 changes: 3 additions & 0 deletions src/player/shooting/rocket_explosion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ pub fn check_explosion(
rocket_explosion.frame += 1;

for (mut player, player_transform) in &mut players {
if player.handle == rocket_explosion.handle {
continue;
}
if player.dodging {
continue;
}
Expand Down
3 changes: 2 additions & 1 deletion src/ui/matchmaking_screen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ struct MatchmakingScreen;
struct MatchmakingText;

const MESSAGE: &str = "WAITING FOR 1 OTHER PLAYER";
const LOADING_TICKER_TIME: f32 = 0.15;

fn spawn_title_text(commands: &mut Commands, font: Handle<Font>) -> Entity {
let text_style = TextStyle {
Expand Down Expand Up @@ -84,7 +85,7 @@ fn animate_matchmaking_screen(
};

*ticks += time.delta_seconds();
if *ticks < 0.2 {
if *ticks < LOADING_TICKER_TIME {
return;
}
*ticks = 0.0;
Expand Down

0 comments on commit 7b2b5d0

Please sign in to comment.