- commit
- 958497ea76510fa4ce9007cd07eed14882adda4e
- parent
- 27a37b70e7b8bc6c0d53e3b8d1b114f6c328252c
- Author
- Tobias Bengfort <tobias.bengfort@posteo.de>
- Date
- 2023-03-29 05:54
fix division by 0
Diffstat
| M | src/weapons.rs | 5 | ++++- |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/weapons.rs b/src/weapons.rs
@@ -50,8 +50,11 @@ pub fn move_straight(projectile: &mut Projectile, _center: &Pos, speed: f32, dt: 50 50 } 51 51 52 52 pub fn move_diagonal(projectile: &mut Projectile, center: &Pos, speed: f32, dt: f32) {53 -1 let dx = projectile.p.x - center.x;-1 53 let mut dx = projectile.p.x - center.x; 54 54 let dy = projectile.p.y - center.y; -1 55 if dx == 0.0 && dy == 0.0 { -1 56 dx = 1.0; -1 57 } 55 58 let r = f32::sqrt(dx * dx + dy * dy); 56 59 57 60 let r2 = r + speed * dt;