mirror of
https://github.com/raysan5/raylib.git
synced 2026-03-10 02:55:41 +00:00
Update textures_bunnymark.c
This commit is contained in:
@@ -17,7 +17,7 @@
|
||||
|
||||
#include <stdlib.h> // Required for: malloc(), free()
|
||||
|
||||
#define MAX_BUNNIES 50000 // 50K bunnies limit
|
||||
#define MAX_BUNNIES 80000 // 80K bunnies limit
|
||||
|
||||
// This is the maximum amount of elements (quads) per batch
|
||||
// NOTE: This value is defined in [rlgl] module and can be changed there
|
||||
@@ -51,7 +51,9 @@ int main(void)
|
||||
|
||||
int bunniesCount = 0; // Bunnies counter
|
||||
|
||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||
bool paused = false;
|
||||
|
||||
//SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
@@ -67,8 +69,8 @@ int main(void)
|
||||
if (bunniesCount < MAX_BUNNIES)
|
||||
{
|
||||
bunnies[bunniesCount].position = GetMousePosition();
|
||||
bunnies[bunniesCount].speed.x = (float)GetRandomValue(-250, 250)/60.0f;
|
||||
bunnies[bunniesCount].speed.y = (float)GetRandomValue(-250, 250)/60.0f;
|
||||
bunnies[bunniesCount].speed.x = (float)GetRandomValue(-250, 250);
|
||||
bunnies[bunniesCount].speed.y = (float)GetRandomValue(-250, 250);
|
||||
bunnies[bunniesCount].color = (Color){ GetRandomValue(50, 240),
|
||||
GetRandomValue(80, 240),
|
||||
GetRandomValue(100, 240), 255 };
|
||||
@@ -77,16 +79,21 @@ int main(void)
|
||||
}
|
||||
}
|
||||
|
||||
// Update bunnies
|
||||
for (int i = 0; i < bunniesCount; i++)
|
||||
{
|
||||
bunnies[i].position.x += bunnies[i].speed.x;
|
||||
bunnies[i].position.y += bunnies[i].speed.y;
|
||||
if (IsKeyPressed(KEY_P)) paused = !paused;
|
||||
|
||||
if (((bunnies[i].position.x + (float)texBunny.width/2) > GetScreenWidth()) ||
|
||||
((bunnies[i].position.x + (float)texBunny.width/2) < 0)) bunnies[i].speed.x *= -1;
|
||||
if (((bunnies[i].position.y + (float)texBunny.height/2) > GetScreenHeight()) ||
|
||||
((bunnies[i].position.y + (float)texBunny.height/2 - 40) < 0)) bunnies[i].speed.y *= -1;
|
||||
if (!paused)
|
||||
{
|
||||
// Update bunnies
|
||||
for (int i = 0; i < bunniesCount; i++)
|
||||
{
|
||||
bunnies[i].position.x += bunnies[i].speed.x*GetFrameTime();
|
||||
bunnies[i].position.y += bunnies[i].speed.y*GetFrameTime();
|
||||
|
||||
if (((bunnies[i].position.x + (float)texBunny.width/2) > GetScreenWidth()) ||
|
||||
((bunnies[i].position.x + (float)texBunny.width/2) < 0)) bunnies[i].speed.x *= -1;
|
||||
if (((bunnies[i].position.y + (float)texBunny.height/2) > GetScreenHeight()) ||
|
||||
((bunnies[i].position.y + (float)texBunny.height/2 - 40) < 0)) bunnies[i].speed.y *= -1;
|
||||
}
|
||||
}
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
|
||||
Reference in New Issue
Block a user