Overworld Movement #9

Merged
msrd0 merged 9 commits from move_overworld into main 2024-07-07 08:49:20 +00:00
2 changed files with 8 additions and 4 deletions
Showing only changes of commit d273e87b55 - Show all commits

View file

@ -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;
}

View file

@ -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;
}