mirror of
https://github.com/raysan5/raylib.git
synced 2026-04-28 01:27:25 -04:00
Fix Memory out of bounds in [shapes] example - ball physics (#5683)
Update screenshot to shapes_bouncing_ball.png
This commit is contained in:
@ -45,7 +45,8 @@ int main(void)
|
|||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [shapes] example - ball physics");
|
InitWindow(screenWidth, screenHeight, "raylib [shapes] example - ball physics");
|
||||||
|
|
||||||
Ball balls[MAX_BALLS] = {{
|
Ball *balls = (Ball*)malloc(sizeof(Ball)*MAX_BALLS);
|
||||||
|
balls[0] = (Ball){
|
||||||
.pos = { GetScreenWidth()/2.0f, GetScreenHeight()/2.0f },
|
.pos = { GetScreenWidth()/2.0f, GetScreenHeight()/2.0f },
|
||||||
.vel = { 200, 200 },
|
.vel = { 200, 200 },
|
||||||
.ppos = { 0 },
|
.ppos = { 0 },
|
||||||
@ -54,7 +55,7 @@ int main(void)
|
|||||||
.elasticity = 0.9f,
|
.elasticity = 0.9f,
|
||||||
.color = BLUE,
|
.color = BLUE,
|
||||||
.grabbed = false
|
.grabbed = false
|
||||||
}};
|
};
|
||||||
|
|
||||||
int ballCount = 1;
|
int ballCount = 1;
|
||||||
Ball *grabbedBall = NULL; // A pointer to the current ball that is grabbed
|
Ball *grabbedBall = NULL; // A pointer to the current ball that is grabbed
|
||||||
@ -214,6 +215,7 @@ int main(void)
|
|||||||
|
|
||||||
// De-Initialization
|
// De-Initialization
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
free(balls);
|
||||||
CloseWindow(); // Close window and OpenGL context
|
CloseWindow(); // Close window and OpenGL context
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 9.3 KiB |
Reference in New Issue
Block a user