diff --git a/src/corelib/world.c b/src/corelib/world.c index 57c64f1..4545b1e 100644 --- a/src/corelib/world.c +++ b/src/corelib/world.c @@ -173,6 +173,7 @@ void interpolate_move(object_t* object, float target_x, float target_y, float ma float m = sqrtf(dx*dx + dy*dy); dx /= m; dy /= m; dx *= max_step_size; dy *= max_step_size; + int step_count = max_step_size / m; // ensure this object would ever collide // if it wouldn't collide anyway, just set position @@ -186,7 +187,7 @@ void interpolate_move(object_t* object, float target_x, float target_y, float ma * 1. move towards target * 2. check collision with every other object */ - while(object->sprite.x != target_x || object->sprite.y != target_y) { + for(int steps = 0; steps < step_count; ++steps) { // move towards target, snap to target if distance is too low const float old_x = object->sprite.x, old_y = object->sprite.y; float new_x, new_y;