simplified
This commit is contained in:
parent
c4d547520e
commit
04754db916
2 changed files with 1 additions and 12 deletions
|
|
@ -98,6 +98,4 @@ pub struct BallProjectile {
|
||||||
pub velocity: Vec2,
|
pub velocity: Vec2,
|
||||||
pub previous_position: Vec2,
|
pub previous_position: Vec2,
|
||||||
pub ball_type: BallType,
|
pub ball_type: BallType,
|
||||||
pub is_fresh: bool,
|
|
||||||
pub travel_distance: f32,
|
|
||||||
}
|
}
|
||||||
|
|
@ -84,8 +84,6 @@ pub fn spawn_projectile_from_cannon(
|
||||||
velocity: direction * 800.0,
|
velocity: direction * 800.0,
|
||||||
previous_position: spawn_pos_2d,
|
previous_position: spawn_pos_2d,
|
||||||
ball_type,
|
ball_type,
|
||||||
is_fresh: true,
|
|
||||||
travel_distance: 0.0,
|
|
||||||
},
|
},
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
@ -100,8 +98,6 @@ pub fn move_projectiles(
|
||||||
let delta = proj.velocity * time.delta_secs();
|
let delta = proj.velocity * time.delta_secs();
|
||||||
let new_pos = proj.previous_position + delta;
|
let new_pos = proj.previous_position + delta;
|
||||||
|
|
||||||
proj.travel_distance += delta.length();
|
|
||||||
|
|
||||||
transform.translation = new_pos.extend(transform.translation.z);
|
transform.translation = new_pos.extend(transform.translation.z);
|
||||||
proj.previous_position = new_pos;
|
proj.previous_position = new_pos;
|
||||||
|
|
||||||
|
|
@ -125,12 +121,7 @@ pub fn detect_projectile_hit(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (proj_entity, mut proj) in projectiles.iter_mut() {
|
for (proj_entity, proj) in projectiles.iter_mut() {
|
||||||
if proj.is_fresh {
|
|
||||||
proj.is_fresh = false;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut min_dist_any = f32::MAX;
|
let mut min_dist_any = f32::MAX;
|
||||||
let mut nearest_idx_any = 0;
|
let mut nearest_idx_any = 0;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue