way better attempt at movement
This commit is contained in:
parent
d273e87b55
commit
89bc156f52
1 changed files with 5 additions and 4 deletions
|
@ -31,14 +31,15 @@ impl Ghost {
|
||||||
let secs = now
|
let secs = now
|
||||||
.duration_since(self.overworld_pos_last_update)
|
.duration_since(self.overworld_pos_last_update)
|
||||||
.as_secs_f32();
|
.as_secs_f32();
|
||||||
let mut movement =
|
let mut movement = self.overworld_movement_pending.signum()
|
||||||
self.overworld_movement_pending * self.overworld_movement_speed * secs;
|
* self.overworld_movement_speed
|
||||||
|
* secs;
|
||||||
|
|
||||||
// limit the movement to the remaining movement
|
// 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;
|
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;
|
movement.y = self.overworld_movement_pending.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue