yaaaa rebota todo

This commit is contained in:
2024-08-21 12:09:32 +02:00
parent 36cb6154d7
commit cdd6e7bc5d
4 changed files with 18 additions and 19 deletions
+5 -5
View File
@@ -16,14 +16,14 @@ int test[5] = {1, 10, 100, 500, 1000};
bool shouldExit = false;
Uint32 ticks = 0;
void initBalls()
void initBalls(int value)
{
for (int i = 0; i < test[0]; ++i)
for (int i = 0; i < test[value]; ++i)
{
const int sign = ((rand() % 2) * 2) - 1;;
const float x = SCREEN_WIDTH / 2 - BALL_SIZE / 2;
const float x = (rand()%(SCREEN_WIDTH/2)) + (SCREEN_WIDTH / 4);
const float vx = (((rand() % 20) + 10) * 0.1f) * sign;
const float vy = ((rand() % 40) - 20) * 0.1f;
const float vy = ((rand() % 60) - 30) * 0.1f;
const color_t color = {(rand() % 192) + 32, (rand() % 192) + 32, (rand() % 192) + 32};
Ball *b = new Ball(x, vx, vy, color, texture);
balls.push_back(b);
@@ -88,7 +88,7 @@ bool init()
texture = new Texture(renderer, "resources/pelota.png");
ticks = SDL_GetTicks();
srand (time(NULL));
initBalls();
initBalls(2);
return success;
}