Pequeños arreglos en la interfaz
This commit is contained in:
@@ -6,8 +6,8 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
SDL_Window *window = NULL;
|
SDL_Window *window = nullptr;
|
||||||
SDL_Renderer *renderer = NULL;
|
SDL_Renderer *renderer = nullptr;
|
||||||
SDL_Event *event;
|
SDL_Event *event;
|
||||||
Texture *texture = nullptr;
|
Texture *texture = nullptr;
|
||||||
std::vector<Ball *> balls;
|
std::vector<Ball *> balls;
|
||||||
@@ -47,6 +47,7 @@ void initBalls(int value)
|
|||||||
Ball *b = new Ball(x, vx, vy, color, texture);
|
Ball *b = new Ball(x, vx, vy, color, texture);
|
||||||
balls.push_back(b);
|
balls.push_back(b);
|
||||||
}
|
}
|
||||||
|
setText();
|
||||||
}
|
}
|
||||||
|
|
||||||
void pushUpBalls()
|
void pushUpBalls()
|
||||||
@@ -88,7 +89,7 @@ bool init()
|
|||||||
{
|
{
|
||||||
// Create window
|
// Create window
|
||||||
window = SDL_CreateWindow(WINDOW_CAPTION, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH * 2, SCREEN_HEIGHT * 2, SDL_WINDOW_SHOWN);
|
window = SDL_CreateWindow(WINDOW_CAPTION, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH * 2, SCREEN_HEIGHT * 2, SDL_WINDOW_SHOWN);
|
||||||
if (window == NULL)
|
if (window == nullptr)
|
||||||
{
|
{
|
||||||
printf("Window could not be created! SDL Error: %s\n", SDL_GetError());
|
printf("Window could not be created! SDL Error: %s\n", SDL_GetError());
|
||||||
success = false;
|
success = false;
|
||||||
@@ -97,7 +98,7 @@ bool init()
|
|||||||
{
|
{
|
||||||
// Create renderer for window
|
// Create renderer for window
|
||||||
renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);
|
renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);
|
||||||
if (renderer == NULL)
|
if (renderer == nullptr)
|
||||||
{
|
{
|
||||||
printf("Renderer could not be created! SDL Error: %s\n", SDL_GetError());
|
printf("Renderer could not be created! SDL Error: %s\n", SDL_GetError());
|
||||||
success = false;
|
success = false;
|
||||||
@@ -117,10 +118,9 @@ bool init()
|
|||||||
|
|
||||||
texture = new Texture(renderer, "resources/pelota.png");
|
texture = new Texture(renderer, "resources/pelota.png");
|
||||||
ticks = SDL_GetTicks();
|
ticks = SDL_GetTicks();
|
||||||
srand(time(NULL));
|
srand(time(nullptr));
|
||||||
dbg_init(renderer);
|
dbg_init(renderer);
|
||||||
initBalls(index);
|
initBalls(index);
|
||||||
setText();
|
|
||||||
|
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
@@ -165,60 +165,65 @@ void checkEvents()
|
|||||||
|
|
||||||
if (event->type == SDL_KEYDOWN && event->key.repeat == 0)
|
if (event->type == SDL_KEYDOWN && event->key.repeat == 0)
|
||||||
{
|
{
|
||||||
if (event->key.keysym.sym == SDLK_SPACE)
|
if (event->key.keysym.sym == SDLK_ESCAPE)
|
||||||
|
{
|
||||||
|
shouldExit = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (event->key.keysym.sym == SDLK_SPACE)
|
||||||
{
|
{
|
||||||
pushUpBalls();
|
pushUpBalls();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event->key.keysym.sym == SDLK_1)
|
else if (event->key.keysym.sym == SDLK_1)
|
||||||
{
|
{
|
||||||
index = 0;
|
index = 0;
|
||||||
initBalls(index);
|
initBalls(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event->key.keysym.sym == SDLK_2)
|
else if (event->key.keysym.sym == SDLK_2)
|
||||||
{
|
{
|
||||||
index = 1;
|
index = 1;
|
||||||
initBalls(index);
|
initBalls(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event->key.keysym.sym == SDLK_3)
|
else if (event->key.keysym.sym == SDLK_3)
|
||||||
{
|
{
|
||||||
index = 2;
|
index = 2;
|
||||||
initBalls(index);
|
initBalls(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event->key.keysym.sym == SDLK_4)
|
else if (event->key.keysym.sym == SDLK_4)
|
||||||
{
|
{
|
||||||
index = 3;
|
index = 3;
|
||||||
initBalls(index);
|
initBalls(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event->key.keysym.sym == SDLK_5)
|
else if (event->key.keysym.sym == SDLK_5)
|
||||||
{
|
{
|
||||||
index = 4;
|
index = 4;
|
||||||
initBalls(index);
|
initBalls(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event->key.keysym.sym == SDLK_6)
|
else if (event->key.keysym.sym == SDLK_6)
|
||||||
{
|
{
|
||||||
index = 5;
|
index = 5;
|
||||||
initBalls(index);
|
initBalls(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event->key.keysym.sym == SDLK_7)
|
else if (event->key.keysym.sym == SDLK_7)
|
||||||
{
|
{
|
||||||
index = 6;
|
index = 6;
|
||||||
initBalls(index);
|
initBalls(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event->key.keysym.sym == SDLK_8)
|
else if (event->key.keysym.sym == SDLK_8)
|
||||||
{
|
{
|
||||||
index = 7;
|
index = 7;
|
||||||
initBalls(index);
|
initBalls(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
setText();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user