File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1616********************************************************************************************/
1717
1818#include "raylib.h"
19+
1920#include "raymath.h"
2021
2122#include <stdlib.h> // Required for: malloc(), free()
@@ -131,12 +132,14 @@ int main(void)
131132 }
132133 }
133134
134- Vector2 windowPositionDiff = Vector2Subtract (windowPosition , GetWindowPosition ());
135- if (Vector2Length (windowPositionDiff ) > 5.0f ) {
136- for (int i = 0 ; i < ballCount ; i ++ ) {
137- if (!balls [i ].grabbed ) {
138- balls [i ].speed = Vector2Add (balls [i ].speed , Vector2Scale (windowPositionDiff , 10.0f ));
139- }
135+ // Get window position change for shaking
136+ Vector2 windowPositionDelta = Vector2Subtract (windowPosition , GetWindowPosition ());
137+
138+ if (Vector2Length (windowPositionDelta ) > 5.0f )
139+ {
140+ for (int i = 0 ; i < ballCount ; i ++ )
141+ {
142+ if (!balls [i ].grabbed ) balls [i ].speed = Vector2Add (balls [i ].speed , Vector2Scale (windowPositionDelta , 10.0f ));
140143 }
141144 }
142145
@@ -236,6 +239,7 @@ int main(void)
236239 // De-Initialization
237240 //--------------------------------------------------------------------------------------
238241 RL_FREE (balls );
242+
239243 CloseWindow (); // Close window and OpenGL context
240244 //--------------------------------------------------------------------------------------
241245
You can’t perform that action at this time.
0 commit comments