don't move with infinetly much missing

This commit is contained in:
Dominic 2024-07-07 10:35:07 +02:00
parent 642aed6023
commit d273e87b55
Signed by: msrd0
GPG key ID: AAF7C8430CA3345D
2 changed files with 8 additions and 4 deletions

View file

@ -3,8 +3,8 @@ use crate::{
State State
}; };
use comfy::{ use comfy::{
draw_circle, draw_rect_outline, draw_sprite, error, is_key_down, is_key_pressed, draw_circle, draw_rect_outline, draw_sprite, error, info, is_key_down,
main_camera_mut, EngineContext, IVec2, KeyCode, Vec2, RED, WHITE is_key_pressed, main_camera_mut, EngineContext, IVec2, KeyCode, Vec2, RED, WHITE
}; };
use std::time::Instant; use std::time::Instant;
use worldgen::MovementCost; use worldgen::MovementCost;
@ -34,6 +34,10 @@ fn update_move_player(state: &mut State) {
// Are there any pending position updates? If so, we ignore all user input and execute // Are there any pending position updates? If so, we ignore all user input and execute
// the pending updates. // the pending updates.
if state.ghost.overworld_movement_pending != Vec2::ZERO { if state.ghost.overworld_movement_pending != Vec2::ZERO {
info!(
"Pending Movement: {:?}",
state.ghost.overworld_movement_pending
);
state.ghost.update_overworld_pos(now); state.ghost.update_overworld_pos(now);
return; return;
} }

View file

@ -35,10 +35,10 @@ impl Ghost {
self.overworld_movement_pending * self.overworld_movement_speed * secs; self.overworld_movement_pending * 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() { if self.overworld_movement_pending.x.abs() < movement.x.abs() + 1e-2 {
movement.x = self.overworld_movement_pending.x; movement.x = self.overworld_movement_pending.x;
} }
if self.overworld_movement_pending.y.abs() < movement.y.abs() { if self.overworld_movement_pending.y.abs() < movement.y.abs() + 1e-2 {
movement.y = self.overworld_movement_pending.y; movement.y = self.overworld_movement_pending.y;
} }