From d273e87b55667dd6e2a9242b7bab398d43409432 Mon Sep 17 00:00:00 2001 From: Dominic Date: Sun, 7 Jul 2024 10:35:07 +0200 Subject: [PATCH] don't move with infinetly much missing --- src/activities/overworld/mod.rs | 8 ++++++-- src/game.rs | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/activities/overworld/mod.rs b/src/activities/overworld/mod.rs index 12dc2e7..68c0764 100644 --- a/src/activities/overworld/mod.rs +++ b/src/activities/overworld/mod.rs @@ -3,8 +3,8 @@ use crate::{ State }; use comfy::{ - draw_circle, draw_rect_outline, draw_sprite, error, is_key_down, is_key_pressed, - main_camera_mut, EngineContext, IVec2, KeyCode, Vec2, RED, WHITE + draw_circle, draw_rect_outline, draw_sprite, error, info, is_key_down, + is_key_pressed, main_camera_mut, EngineContext, IVec2, KeyCode, Vec2, RED, WHITE }; use std::time::Instant; 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 // the pending updates. if state.ghost.overworld_movement_pending != Vec2::ZERO { + info!( + "Pending Movement: {:?}", + state.ghost.overworld_movement_pending + ); state.ghost.update_overworld_pos(now); return; } diff --git a/src/game.rs b/src/game.rs index 4215d64..7613efd 100644 --- a/src/game.rs +++ b/src/game.rs @@ -35,10 +35,10 @@ impl Ghost { self.overworld_movement_pending * self.overworld_movement_speed * secs; // 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; } - 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; }