Añadido el logo actual
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 2.5 KiB |
BIN
data/gfx/logo_jailgames.png
Normal file
BIN
data/gfx/logo_jailgames.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 717 B |
BIN
data/gfx/logo_since_1998.png
Normal file
BIN
data/gfx/logo_since_1998.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 561 B |
@@ -16,7 +16,7 @@ Director::Director(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
// Inicializa variables
|
// Inicializa variables
|
||||||
section = new section_t();
|
section = new section_t();
|
||||||
section->name = SECTION_PROG_TITLE;
|
section->name = SECTION_PROG_LOGO;
|
||||||
|
|
||||||
// Inicializa las opciones del programa
|
// Inicializa las opciones del programa
|
||||||
initOptions();
|
initOptions();
|
||||||
@@ -287,7 +287,8 @@ bool Director::setFileList()
|
|||||||
asset->add(prefix + "/data/gfx/game_text.png", t_bitmap);
|
asset->add(prefix + "/data/gfx/game_text.png", t_bitmap);
|
||||||
|
|
||||||
asset->add(prefix + "/data/gfx/intro.png", t_bitmap);
|
asset->add(prefix + "/data/gfx/intro.png", t_bitmap);
|
||||||
asset->add(prefix + "/data/gfx/logo.png", t_bitmap);
|
asset->add(prefix + "/data/gfx/logo_jailgames.png", t_bitmap);
|
||||||
|
asset->add(prefix + "/data/gfx/logo_since_1998.png", t_bitmap);
|
||||||
asset->add(prefix + "/data/gfx/menu_game_over.png", t_bitmap);
|
asset->add(prefix + "/data/gfx/menu_game_over.png", t_bitmap);
|
||||||
asset->add(prefix + "/data/gfx/menu_game_over_end.png", t_bitmap);
|
asset->add(prefix + "/data/gfx/menu_game_over_end.png", t_bitmap);
|
||||||
|
|
||||||
|
|||||||
229
source/logo.cpp
229
source/logo.cpp
@@ -1,7 +1,5 @@
|
|||||||
#include "logo.h"
|
#include "logo.h"
|
||||||
|
#include <iostream>
|
||||||
#define INIT_FADE 100
|
|
||||||
#define END_LOGO 200
|
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Logo::Logo(SDL_Renderer *renderer, Screen *screen, Asset *asset, Input *input, section_t *section)
|
Logo::Logo(SDL_Renderer *renderer, Screen *screen, Asset *asset, Input *input, section_t *section)
|
||||||
@@ -15,38 +13,61 @@ Logo::Logo(SDL_Renderer *renderer, Screen *screen, Asset *asset, Input *input, s
|
|||||||
|
|
||||||
// Reserva memoria para los punteros
|
// Reserva memoria para los punteros
|
||||||
eventHandler = new SDL_Event();
|
eventHandler = new SDL_Event();
|
||||||
texture = new Texture(renderer, asset->get("logo.png"));
|
texture = new Texture(renderer, asset->get("logo_jailgames.png"));
|
||||||
sprite = new Sprite(14, 75, 226, 44, texture, renderer);
|
texture2 = new Texture(renderer, asset->get("logo_since_1998.png"));
|
||||||
|
sprite2 = new Sprite((256 - texture2->getWidth()) / 2, 83 + texture->getHeight() + 5, texture2->getWidth(), texture2->getHeight(), texture2, renderer);
|
||||||
|
sprite2->setSpriteClip(0, 0, texture2->getWidth(), texture2->getHeight());
|
||||||
|
texture2->setColor(0, 0, 0);
|
||||||
|
|
||||||
|
// Crea los sprites de cada linea
|
||||||
|
for (int i = 0; i < texture->getHeight(); ++i)
|
||||||
|
{
|
||||||
|
sprite.push_back(new Sprite(0, i, texture->getWidth(), 1, texture, renderer));
|
||||||
|
sprite.back()->setSpriteClip(0, i, texture->getWidth(), 1);
|
||||||
|
if (i % 2 == 0)
|
||||||
|
{
|
||||||
|
sprite[i]->setPosX(256 + (i * 3));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sprite[i]->setPosX(-181 - (i * 3));
|
||||||
|
}
|
||||||
|
sprite[i]->setPosY(83 + i);
|
||||||
|
}
|
||||||
|
|
||||||
// Inicializa variables
|
// Inicializa variables
|
||||||
counter = 0;
|
counter = 0;
|
||||||
section->name = SECTION_PROG_LOGO;
|
section->name = SECTION_PROG_LOGO;
|
||||||
section->subsection = 0;
|
|
||||||
ticks = 0;
|
ticks = 0;
|
||||||
ticksSpeed = 15;
|
ticksSpeed = 15;
|
||||||
|
initFade = 300;
|
||||||
|
endLogo = 400;
|
||||||
|
postLogo = 20;
|
||||||
|
|
||||||
|
// Inicializa el vector de colores
|
||||||
|
color.push_back({0x00, 0x00, 0x00}); // Black
|
||||||
|
color.push_back({0x00, 0x00, 0xd8}); // Blue
|
||||||
|
color.push_back({0xd8, 0x00, 0x00}); // Red
|
||||||
|
color.push_back({0xd8, 0x00, 0xd8}); // Magenta
|
||||||
|
color.push_back({0x00, 0xd8, 0x00}); // Green
|
||||||
|
color.push_back({0x00, 0xd8, 0xd8}); // Cyan
|
||||||
|
color.push_back({0xd8, 0xd8, 0x00}); // Yellow
|
||||||
|
color.push_back({0xFF, 0xFF, 0xFF}); // Bright white
|
||||||
}
|
}
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
Logo::~Logo()
|
Logo::~Logo()
|
||||||
{
|
{
|
||||||
texture->unload();
|
for (auto s : sprite)
|
||||||
delete texture;
|
{
|
||||||
|
delete s;
|
||||||
|
}
|
||||||
|
|
||||||
delete sprite;
|
delete sprite2;
|
||||||
delete eventHandler;
|
delete eventHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Comprueba si ha terminado el logo
|
// Comprueba el manejador de eventos
|
||||||
void Logo::checkLogoEnd()
|
|
||||||
{
|
|
||||||
if (counter >= END_LOGO + 20)
|
|
||||||
{
|
|
||||||
section->name = SECTION_PROG_INTRO;
|
|
||||||
section->subsection = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Comprueba los eventos
|
|
||||||
void Logo::checkEvents()
|
void Logo::checkEvents()
|
||||||
{
|
{
|
||||||
// Comprueba los eventos que hay en la cola
|
// Comprueba los eventos que hay en la cola
|
||||||
@@ -66,7 +87,7 @@ void Logo::checkInput()
|
|||||||
{
|
{
|
||||||
if (input->checkInput(input_exit, REPEAT_FALSE))
|
if (input->checkInput(input_exit, REPEAT_FALSE))
|
||||||
{
|
{
|
||||||
section->name = SECTION_PROG_QUIT;
|
section->name = SECTION_PROG_TITLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (input->checkInput(input_window_fullscreen, REPEAT_FALSE))
|
else if (input->checkInput(input_window_fullscreen, REPEAT_FALSE))
|
||||||
@@ -84,58 +105,179 @@ void Logo::checkInput()
|
|||||||
screen->incWindowSize();
|
screen->incWindowSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (input->checkInput(input_pause, REPEAT_FALSE) || input->checkInput(input_accept, REPEAT_FALSE) || input->checkInput(input_fire_left, REPEAT_FALSE) || input->checkInput(input_fire_center, REPEAT_FALSE) || input->checkInput(input_fire_right, REPEAT_FALSE))
|
//else if (input->checkInput(input_pause, REPEAT_FALSE) || input->checkInput(input_accept, REPEAT_FALSE) || input->checkInput(input_jump, REPEAT_FALSE))
|
||||||
|
//{
|
||||||
|
// section->name = SECTION_PROG_TITLE;
|
||||||
|
// section->subsection = SUBSECTION_TITLE_1;
|
||||||
|
// endSection();
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Gestiona el logo de JAILGAME
|
||||||
|
void Logo::updateJAILGAMES()
|
||||||
{
|
{
|
||||||
section->name = SECTION_PROG_TITLE;
|
if (counter > 30)
|
||||||
section->subsection = SUBSECTION_TITLE_1;
|
{
|
||||||
|
for (int i = 1; i < (int)sprite.size(); ++i)
|
||||||
|
{
|
||||||
|
const int speed = 8;
|
||||||
|
const int dest = 37;
|
||||||
|
if (sprite[i]->getPosX() != 37)
|
||||||
|
{
|
||||||
|
if (i % 2 == 0)
|
||||||
|
{
|
||||||
|
sprite[i]->incPosX(-speed);
|
||||||
|
if (sprite[i]->getPosX() < dest)
|
||||||
|
{
|
||||||
|
sprite[i]->setPosX(dest);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sprite[i]->incPosX(speed);
|
||||||
|
if (sprite[i]->getPosX() > dest)
|
||||||
|
{
|
||||||
|
sprite[i]->setPosX(dest);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dibuja el fade
|
// Gestiona el color de las texturas
|
||||||
void Logo::renderFade()
|
void Logo::updateTextureColors()
|
||||||
{
|
{
|
||||||
// Dibuja el fade
|
const int ini = 70;
|
||||||
if (counter >= INIT_FADE)
|
const int inc = 4;
|
||||||
|
|
||||||
|
if (counter == ini + inc * 0)
|
||||||
{
|
{
|
||||||
const float step = (float)(counter - INIT_FADE) / (float)(END_LOGO - INIT_FADE);
|
texture2->setColor(color[0].r, color[0].g, color[0].b);
|
||||||
const int alpha = std::min((int)(255 * step), 255);
|
}
|
||||||
SDL_SetRenderDrawColor(renderer, bgColor.r, bgColor.g, bgColor.b, alpha);
|
|
||||||
SDL_RenderFillRect(renderer, nullptr);
|
else if (counter == ini + inc * 1)
|
||||||
|
{
|
||||||
|
texture2->setColor(color[1].r, color[1].g, color[1].b);
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (counter == ini + inc * 2)
|
||||||
|
{
|
||||||
|
texture2->setColor(color[2].r, color[2].g, color[2].b);
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (counter == ini + inc * 3)
|
||||||
|
{
|
||||||
|
texture2->setColor(color[3].r, color[3].g, color[3].b);
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (counter == ini + inc * 4)
|
||||||
|
{
|
||||||
|
texture2->setColor(color[4].r, color[4].g, color[4].b);
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (counter == ini + inc * 5)
|
||||||
|
{
|
||||||
|
texture2->setColor(color[5].r, color[5].g, color[5].b);
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (counter == ini + inc * 6)
|
||||||
|
{
|
||||||
|
texture2->setColor(color[6].r, color[6].g, color[6].b);
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (counter == ini + inc * 7)
|
||||||
|
{
|
||||||
|
texture2->setColor(color[7].r, color[7].g, color[7].b);
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (counter == initFade + inc * 0)
|
||||||
|
{
|
||||||
|
texture->setColor(color[6].r, color[6].g, color[6].b);
|
||||||
|
texture2->setColor(color[6].r, color[6].g, color[6].b);
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (counter == initFade + inc * 1)
|
||||||
|
{
|
||||||
|
texture->setColor(color[5].r, color[5].g, color[5].b);
|
||||||
|
texture2->setColor(color[5].r, color[5].g, color[5].b);
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (counter == initFade + inc * 2)
|
||||||
|
{
|
||||||
|
texture->setColor(color[4].r, color[4].g, color[4].b);
|
||||||
|
texture2->setColor(color[4].r, color[4].g, color[4].b);
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (counter == initFade + inc * 3)
|
||||||
|
{
|
||||||
|
texture->setColor(color[3].r, color[3].g, color[3].b);
|
||||||
|
texture2->setColor(color[3].r, color[3].g, color[3].b);
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (counter == initFade + inc * 4)
|
||||||
|
{
|
||||||
|
texture->setColor(color[2].r, color[2].g, color[2].b);
|
||||||
|
texture2->setColor(color[2].r, color[2].g, color[2].b);
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (counter == initFade + inc * 5)
|
||||||
|
{
|
||||||
|
texture->setColor(color[1].r, color[1].g, color[1].b);
|
||||||
|
texture2->setColor(color[1].r, color[1].g, color[1].b);
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (counter == initFade + inc * 6)
|
||||||
|
{
|
||||||
|
texture->setColor(color[0].r, color[0].g, color[0].b);
|
||||||
|
texture2->setColor(color[0].r, color[0].g, color[0].b);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actualiza las variables del objeto
|
// Actualiza las variables
|
||||||
void Logo::update()
|
void Logo::update()
|
||||||
{
|
{
|
||||||
checkInput();
|
// Comprueba que la diferencia de ticks sea mayor a la velocidad del juego
|
||||||
|
|
||||||
if (SDL_GetTicks() - ticks > ticksSpeed)
|
if (SDL_GetTicks() - ticks > ticksSpeed)
|
||||||
{
|
{
|
||||||
// Actualiza el contador de ticks
|
// Actualiza el contador de ticks
|
||||||
ticks = SDL_GetTicks();
|
ticks = SDL_GetTicks();
|
||||||
|
|
||||||
// Actualiza el contador
|
// Comprueba las entradas
|
||||||
|
checkInput();
|
||||||
|
|
||||||
|
// Incrementa el contador
|
||||||
counter++;
|
counter++;
|
||||||
|
|
||||||
|
// Gestiona el logo de JAILGAME
|
||||||
|
updateJAILGAMES();
|
||||||
|
|
||||||
|
// Gestiona el color de las texturas
|
||||||
|
updateTextureColors();
|
||||||
|
|
||||||
// Comprueba si ha terminado el logo
|
// Comprueba si ha terminado el logo
|
||||||
checkLogoEnd();
|
if (counter == endLogo + postLogo)
|
||||||
|
{
|
||||||
|
section->name = SECTION_PROG_INTRO;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dibuja el objeto en pantalla
|
// Dibuja en pantalla
|
||||||
void Logo::render()
|
void Logo::render()
|
||||||
{
|
{
|
||||||
// Prepara para empezar a dibujar en la textura de juego
|
// Prepara para empezar a dibujar en la textura de juego
|
||||||
screen->start();
|
screen->start();
|
||||||
|
|
||||||
// Limpia la pantalla
|
// Limpia la pantalla
|
||||||
screen->clean({238, 238, 238});
|
screen->clean();
|
||||||
|
|
||||||
// Dibuja los objetos
|
// Dibuja los objetos
|
||||||
sprite->render();
|
for (auto s : sprite)
|
||||||
|
{
|
||||||
// Dibuja el fade
|
s->render();
|
||||||
renderFade();
|
}
|
||||||
|
sprite2->render();
|
||||||
|
|
||||||
// Vuelca el contenido del renderizador en pantalla
|
// Vuelca el contenido del renderizador en pantalla
|
||||||
screen->blit();
|
screen->blit();
|
||||||
@@ -144,6 +286,7 @@ void Logo::render()
|
|||||||
// Bucle para el logo del juego
|
// Bucle para el logo del juego
|
||||||
void Logo::run()
|
void Logo::run()
|
||||||
{
|
{
|
||||||
|
// Detiene la música
|
||||||
JA_StopMusic();
|
JA_StopMusic();
|
||||||
|
|
||||||
while (section->name == SECTION_PROG_LOGO)
|
while (section->name == SECTION_PROG_LOGO)
|
||||||
|
|||||||
@@ -8,46 +8,53 @@
|
|||||||
#include "common/sprite.h"
|
#include "common/sprite.h"
|
||||||
#include "common/utils.h"
|
#include "common/utils.h"
|
||||||
#include "const.h"
|
#include "const.h"
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#ifndef LOGO_H
|
#ifndef LOGO_H
|
||||||
#define LOGO_H
|
#define LOGO_H
|
||||||
|
|
||||||
// Clase Logo
|
|
||||||
class Logo
|
class Logo
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
// Objetos y punteros
|
// Objetos y punteros
|
||||||
SDL_Renderer *renderer; // El renderizador de la ventana
|
SDL_Renderer *renderer; // El renderizador de la ventana
|
||||||
Screen *screen; // Objeto encargado de dibujar en pantalla
|
Screen *screen; // Objeto encargado de dibujar en pantalla
|
||||||
Asset *asset; // Objeto que gestiona todos los ficheros de recursos
|
Asset *asset; // Objeto con los ficheros de recursos
|
||||||
Input *input; // Objeto pata gestionar la entrada
|
Input *input; // Objeto pata gestionar la entrada
|
||||||
Texture *texture; // Textura con los graficos
|
Texture *texture; // Textura con los graficos "JAILGAMES"
|
||||||
|
Texture *texture2; // Textura con los graficos "Since 1998"
|
||||||
SDL_Event *eventHandler; // Manejador de eventos
|
SDL_Event *eventHandler; // Manejador de eventos
|
||||||
Sprite *sprite; // Sprite con la textura del logo
|
std::vector<Sprite *> sprite; // Vector con los sprites de cada linea que forman el bitmap JAILGAMES
|
||||||
|
Sprite *sprite2; // Sprite para manejar la textura2
|
||||||
|
options_t *options; // Puntero a las opciones del juego
|
||||||
section_t *section; // Estado del bucle principal para saber si continua o se sale
|
section_t *section; // Estado del bucle principal para saber si continua o se sale
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
|
std::vector<color_t> color; // Vector con los colores para el fade
|
||||||
|
int counter; // Contador
|
||||||
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
|
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
|
||||||
Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
|
Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
|
||||||
int counter; // Contador
|
int initFade; // Tiempo del contador cuando inicia el fade a negro
|
||||||
|
int endLogo; // Tiempo del contador para terminar el logo
|
||||||
|
int postLogo; // Tiempo que dura el logo con el fade al maximo
|
||||||
|
|
||||||
// Actualiza las variables del objeto
|
// Actualiza las variables
|
||||||
void update();
|
void update();
|
||||||
|
|
||||||
// Dibuja el objeto en pantalla
|
// Dibuja en pantalla
|
||||||
void render();
|
void render();
|
||||||
|
|
||||||
// Comprueba si ha terminado el logo
|
// Comprueba el manejador de eventos
|
||||||
void checkLogoEnd();
|
|
||||||
|
|
||||||
// Comprueba los eventos
|
|
||||||
void checkEvents();
|
void checkEvents();
|
||||||
|
|
||||||
// Comprueba las entradas
|
// Comprueba las entradas
|
||||||
void checkInput();
|
void checkInput();
|
||||||
|
|
||||||
// Dibuja el fade
|
// Gestiona el logo de JAILGAME
|
||||||
void renderFade();
|
void updateJAILGAMES();
|
||||||
|
|
||||||
|
// Gestiona el color de las texturas
|
||||||
|
void updateTextureColors();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
|
|||||||
Reference in New Issue
Block a user