mirror of
https://github.com/raysan5/raylib.git
synced 2026-04-25 08:13:58 -04:00
Update shapes_ball_physics.c
This commit is contained in:
@ -16,6 +16,7 @@
|
|||||||
********************************************************************************************/
|
********************************************************************************************/
|
||||||
|
|
||||||
#include "raylib.h"
|
#include "raylib.h"
|
||||||
|
|
||||||
#include "raymath.h"
|
#include "raymath.h"
|
||||||
|
|
||||||
#include <stdlib.h> // Required for: malloc(), free()
|
#include <stdlib.h> // Required for: malloc(), free()
|
||||||
@ -131,12 +132,14 @@ int main(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector2 windowPositionDiff = Vector2Subtract(windowPosition, GetWindowPosition());
|
// Get window position change for shaking
|
||||||
if (Vector2Length(windowPositionDiff) > 5.0f) {
|
Vector2 windowPositionDelta = Vector2Subtract(windowPosition, GetWindowPosition());
|
||||||
for (int i = 0; i < ballCount; i++) {
|
|
||||||
if (!balls[i].grabbed) {
|
if (Vector2Length(windowPositionDelta) > 5.0f)
|
||||||
balls[i].speed = Vector2Add(balls[i].speed, Vector2Scale(windowPositionDiff, 10.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
|
// De-Initialization
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
RL_FREE(balls);
|
RL_FREE(balls);
|
||||||
|
|
||||||
CloseWindow(); // Close window and OpenGL context
|
CloseWindow(); // Close window and OpenGL context
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user