Overworld Movement #9
2 changed files with 8 additions and 4 deletions
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue