position now resets to last when interpolate_move collides
parent
4bf759d224
commit
d134df5847
|
@ -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 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);
|
const float distx = fabsf(object->sprite.x - target_x), disty = fabsf(object->sprite.y - target_y);
|
||||||
if(distx < fabsf(dx) && disty < fabsf(dy)) {
|
if(distx < fabsf(dx) && disty < fabsf(dy)) {
|
||||||
object->sprite.x += dx; object->sprite.y += dy;
|
object->sprite.x += dx;
|
||||||
|
object->sprite.y += dy;
|
||||||
} else {
|
} else {
|
||||||
object->sprite.x = target_x;
|
object->sprite.x = target_x;
|
||||||
object->sprite.y = target_y;
|
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)) {
|
if(_can_collide(other) && object != other && _collision_check(other, object)) {
|
||||||
object_broadcast_collision(other, object);
|
object_broadcast_collision(other, object);
|
||||||
object_broadcast_collision(object, other);
|
object_broadcast_collision(object, other);
|
||||||
|
object->sprite.x = old_x;
|
||||||
|
object->sprite.y = old_y;
|
||||||
return other;
|
return other;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue