LOGO funcional
This commit is contained in:
@@ -1919,7 +1919,6 @@ void Game::popBalloon(Balloon *balloon)
|
||||
mBalloonsPopped++;
|
||||
|
||||
const Uint8 kind = balloon->getKind();
|
||||
Uint8 freeIndex = 0;
|
||||
switch (kind)
|
||||
{
|
||||
// Si es del tipo más pequeño, simplemente elimina el globo
|
||||
@@ -2265,6 +2264,7 @@ void Game::renderBullets()
|
||||
void Game::createBullet(int x, int y, Uint8 kind, bool poweredUp, int owner)
|
||||
{
|
||||
Bullet *b = new Bullet(x, y, kind, poweredUp, owner, mTextureBullet, mRenderer);
|
||||
bullets.push_back(b);
|
||||
}
|
||||
|
||||
// Actualiza los items
|
||||
|
||||
@@ -16,13 +16,6 @@ Logo::Logo(SDL_Renderer *renderer, Screen *screen, Asset *asset)
|
||||
texture = new LTexture(renderer, asset->get("logo.png"));
|
||||
sprite = new Sprite(0, 0, GAME_WIDTH, GAME_HEIGHT, texture, renderer);
|
||||
|
||||
// Crea un backbuffer para el renderizador
|
||||
backbuffer = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, GAME_WIDTH, GAME_HEIGHT);
|
||||
if (backbuffer == nullptr)
|
||||
{
|
||||
printf("Backbuffer could not be created!\nSDL Error: %s\n", SDL_GetError());
|
||||
}
|
||||
|
||||
// Inicializa variables
|
||||
counter = 0;
|
||||
section.name = PROG_SECTION_LOGO;
|
||||
@@ -34,8 +27,6 @@ Logo::Logo(SDL_Renderer *renderer, Screen *screen, Asset *asset)
|
||||
// Destructor
|
||||
Logo::~Logo()
|
||||
{
|
||||
SDL_DestroyTexture(backbuffer);
|
||||
|
||||
texture->unload();
|
||||
delete texture;
|
||||
|
||||
@@ -46,24 +37,11 @@ Logo::~Logo()
|
||||
// Comprueba si ha terminado el logo
|
||||
void Logo::checkLogoEnd()
|
||||
{
|
||||
if (counter == 0)
|
||||
if (counter >= END_LOGO + 20)
|
||||
{
|
||||
if (JA_GetMusicState() == JA_MUSIC_PLAYING)
|
||||
{
|
||||
JA_StopMusic();
|
||||
}
|
||||
}
|
||||
|
||||
if (counter == END_LOGO + 20)
|
||||
{
|
||||
counter = 0;
|
||||
section.name = PROG_SECTION_INTRO;
|
||||
section.name = PROG_SECTION_QUIT;
|
||||
section.subsection = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
counter++;
|
||||
}
|
||||
}
|
||||
|
||||
// Comprueba los eventos
|
||||
@@ -91,22 +69,13 @@ void Logo::checkEventHandler()
|
||||
// Dibuja el fade
|
||||
void Logo::renderFade()
|
||||
{
|
||||
const SDL_Rect rect = {0, 0, GAME_WIDTH, GAME_HEIGHT};
|
||||
const int fadeLenght = END_LOGO - INIT_FADE;
|
||||
|
||||
// Dibuja el fade
|
||||
if (counter >= INIT_FADE)
|
||||
{
|
||||
const Uint16 alpha = (255 * (counter - INIT_FADE)) / fadeLenght;
|
||||
if (alpha < 256)
|
||||
{
|
||||
const float step = (float)(counter - INIT_FADE) / (float)(END_LOGO - INIT_FADE);
|
||||
const int alpha = std::min((int)(255 * step), 255);
|
||||
SDL_SetRenderDrawColor(renderer, bgColor.r, bgColor.g, bgColor.b, alpha);
|
||||
}
|
||||
else
|
||||
{
|
||||
SDL_SetRenderDrawColor(renderer, bgColor.r, bgColor.g, bgColor.b, 255);
|
||||
}
|
||||
SDL_RenderFillRect(renderer, &rect);
|
||||
SDL_RenderFillRect(renderer, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,6 +89,9 @@ void Logo::update()
|
||||
// Actualiza el contador de ticks
|
||||
ticks = SDL_GetTicks();
|
||||
|
||||
// Actualiza el contador
|
||||
counter++;
|
||||
|
||||
// Comprueba si ha terminado el logo
|
||||
checkLogoEnd();
|
||||
}
|
||||
@@ -147,6 +119,8 @@ void Logo::render()
|
||||
// Bucle para el logo del juego
|
||||
section_t Logo::run()
|
||||
{
|
||||
JA_StopMusic();
|
||||
|
||||
while (section.name == PROG_SECTION_LOGO)
|
||||
{
|
||||
update();
|
||||
|
||||
@@ -15,17 +15,19 @@
|
||||
class Logo
|
||||
{
|
||||
private:
|
||||
// Objetos
|
||||
SDL_Renderer *renderer; // El renderizador de la ventana
|
||||
Screen *screen; // Objeto encargado de dibujar en pantalla
|
||||
Asset *asset; // Objeto que gestiona todos los ficheros de recursos
|
||||
LTexture *texture; // Textura con los graficos
|
||||
SDL_Event *eventHandler; // Manejador de eventos
|
||||
SDL_Texture *backbuffer; // Textura para usar como backbuffer
|
||||
Sprite *sprite; // Sprite con la textura del logo
|
||||
int counter; // Contador
|
||||
section_t section; // Estado del bucle principal para saber si continua o se sale
|
||||
|
||||
// Variables
|
||||
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
|
||||
Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
|
||||
section_t section; // Estado del bucle principal para saber si continua o se sale
|
||||
int counter; // Contador
|
||||
|
||||
// Actualiza las variables del objeto
|
||||
void update();
|
||||
|
||||
Reference in New Issue
Block a user