way better attempt at movement

This commit is contained in:
Dominic 2024-07-07 10:38:09 +02:00
parent d273e87b55
commit 89bc156f52
Signed by: msrd0
GPG key ID: AAF7C8430CA3345D

View file

@ -31,14 +31,15 @@ impl Ghost {
let secs = now
.duration_since(self.overworld_pos_last_update)
.as_secs_f32();
let mut movement =
self.overworld_movement_pending * self.overworld_movement_speed * secs;
let mut movement = self.overworld_movement_pending.signum()
* self.overworld_movement_speed
* secs;
// limit the movement to the remaining movement
if self.overworld_movement_pending.x.abs() < movement.x.abs() + 1e-2 {
if self.overworld_movement_pending.x.abs() < movement.x.abs() {
movement.x = self.overworld_movement_pending.x;
}
if self.overworld_movement_pending.y.abs() < movement.y.abs() + 1e-2 {
if self.overworld_movement_pending.y.abs() < movement.y.abs() {
movement.y = self.overworld_movement_pending.y;
}