From d134df5847b2b88da6c524a6affd36fe0c90946a Mon Sep 17 00:00:00 2001 From: Sara Date: Sun, 18 Jun 2023 13:42:20 +0200 Subject: [PATCH] position now resets to last when interpolate_move collides --- src/corelib/world.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/corelib/world.c b/src/corelib/world.c index 957655e..fa92ea7 100644 --- a/src/corelib/world.c +++ b/src/corelib/world.c @@ -191,7 +191,8 @@ object_t* interpolate_move(object_t* object, float target_x, float target_y, flo const float old_x = object->sprite.x, old_y = object->sprite.y; const float distx = fabsf(object->sprite.x - target_x), disty = fabsf(object->sprite.y - target_y); if(distx < fabsf(dx) && disty < fabsf(dy)) { - object->sprite.x += dx; object->sprite.y += dy; + object->sprite.x += dx; + object->sprite.y += dy; } else { object->sprite.x = target_x; object->sprite.y = target_y; @@ -205,6 +206,8 @@ object_t* interpolate_move(object_t* object, float target_x, float target_y, flo if(_can_collide(other) && object != other && _collision_check(other, object)) { object_broadcast_collision(other, object); object_broadcast_collision(object, other); + object->sprite.x = old_x; + object->sprite.y = old_y; return other; } }