Muchos pequeños cambios para estandarizar y mejorar la demo
This commit is contained in:
+22
-4
@@ -1,4 +1,3 @@
|
||||
#include <SDL2/SDL.h>
|
||||
#include "texture.h"
|
||||
#include "ball.h"
|
||||
#include "defines.h"
|
||||
@@ -54,13 +53,19 @@ bool init()
|
||||
|
||||
event = new SDL_Event();
|
||||
|
||||
texture = new Texture(renderer, "resources/pelota.png");
|
||||
texture = new Texture(renderer, TEXTURE_FILE);
|
||||
for (int i = 0; i < NUM_BALLS; ++i)
|
||||
{
|
||||
ball[i] = new Ball(rand() % SCREEN_WIDTH, rand() % SCREEN_HEIGHT, 24, 24, 1, 1, texture);
|
||||
const int vx = rand() % 2 == 0 ? 1 : -1;
|
||||
const int vy = rand() % 2 == 0 ? 1 : -1;
|
||||
const int x = rand() % SCREEN_WIDTH;
|
||||
const int y = rand() % SCREEN_HEIGHT;
|
||||
const int size = BALL_SIZE;
|
||||
ball[i] = new Ball(x, y, size, size, vx, vy, texture);
|
||||
}
|
||||
|
||||
ticks = SDL_GetTicks();
|
||||
srand(time(NULL));
|
||||
|
||||
return success;
|
||||
}
|
||||
@@ -106,6 +111,19 @@ void checkEvents()
|
||||
shouldExit = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (event->type == SDL_KEYDOWN && event->key.repeat == 0)
|
||||
{
|
||||
switch (event->key.keysym.sym)
|
||||
{
|
||||
case SDLK_ESCAPE:
|
||||
shouldExit = true;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,7 +142,7 @@ void update()
|
||||
|
||||
void render()
|
||||
{
|
||||
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
|
||||
SDL_SetRenderDrawColor(renderer, BG_R, BG_G, BG_B, 255);
|
||||
SDL_RenderClear(renderer);
|
||||
|
||||
for (int i = 0; i < NUM_BALLS; ++i)
|
||||
|
||||
Reference in New Issue
Block a user