- commit
- 62ff9d766c8c6fa457d04d790128cfa83cbfadb1
- parent
- ad4b2f7a700a916431e6bdb0beb268327da5f08d
- Author
- Tobias Bengfort <tobias.bengfort@posteo.de>
- Date
- 2023-03-30 09:01
make move_parabola more varied
Diffstat
| M | src/weapons.rs | 13 | +++++++++++-- |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/weapons.rs b/src/weapons.rs
@@ -44,8 +44,17 @@ pub fn move_diagonal(projectile: &mut Projectile, center: &Pos, speed: f32, dt: 44 44 } 45 45 46 46 pub fn move_parabola(projectile: &mut Projectile, center: &Pos, speed: f32, dt: f32) {47 -1 let t = (projectile.p.x - center.x).abs() / speed;48 -1 projectile.p.y += speed * (4.0 * t - 1.0) * dt;-1 47 let dx = (projectile.p.x - center.x).abs(); -1 48 let mut t = (dx / speed).max(0.1); -1 49 if dx < SPAWN_RADIUS && projectile.p.y > center.y { -1 50 t = -t; -1 51 } -1 52 -1 53 let acc = speed * 6.0; -1 54 let dy = projectile.p.y - center.y; -1 55 let y_speed_0 = (acc * t - dy / t).min(speed * 2.0).max(speed / 2.0); -1 56 -1 57 projectile.p.y += (acc * t - y_speed_0) * dt; 49 58 if projectile.p.x < center.x { 50 59 projectile.p.x -= speed * dt; 51 60 projectile.dir = Dir::Left;