From d892f3ba4ae07d38e008ad37a55c5ffa29be66af Mon Sep 17 00:00:00 2001 From: Ray Date: Fri, 24 Apr 2026 15:11:39 +0200 Subject: [PATCH] Update shapes_ball_physics.c --- examples/shapes/shapes_ball_physics.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/examples/shapes/shapes_ball_physics.c b/examples/shapes/shapes_ball_physics.c index 2424ea738..d94cc438a 100644 --- a/examples/shapes/shapes_ball_physics.c +++ b/examples/shapes/shapes_ball_physics.c @@ -16,6 +16,7 @@ ********************************************************************************************/ #include "raylib.h" + #include "raymath.h" #include // Required for: malloc(), free() @@ -131,12 +132,14 @@ int main(void) } } - Vector2 windowPositionDiff = Vector2Subtract(windowPosition, GetWindowPosition()); - if (Vector2Length(windowPositionDiff) > 5.0f) { - for (int i = 0; i < ballCount; i++) { - if (!balls[i].grabbed) { - balls[i].speed = Vector2Add(balls[i].speed, Vector2Scale(windowPositionDiff, 10.0f)); - } + // Get window position change for shaking + Vector2 windowPositionDelta = Vector2Subtract(windowPosition, GetWindowPosition()); + + if (Vector2Length(windowPositionDelta) > 5.0f) + { + for (int i = 0; i < ballCount; i++) + { + if (!balls[i].grabbed) balls[i].speed = Vector2Add(balls[i].speed, Vector2Scale(windowPositionDelta, 10.0f)); } } @@ -236,6 +239,7 @@ int main(void) // De-Initialization //-------------------------------------------------------------------------------------- RL_FREE(balls); + CloseWindow(); // Close window and OpenGL context //--------------------------------------------------------------------------------------