position now resets to last when interpolate_move collides

pull/6/head
Sara 2023-06-18 13:42:20 +02:00
parent 4bf759d224
commit d134df5847
1 changed files with 4 additions and 1 deletions

View File

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