Creada la clase game_logo para gestionar el logo con el titulo del juego
This commit is contained in:
158
source/title.cpp
158
source/title.cpp
@@ -16,15 +16,6 @@ Title::Title(SDL_Renderer *renderer, Screen *screen, Input *input, Asset *asset,
|
||||
eventHandler = new SDL_Event();
|
||||
fade = new Fade(renderer);
|
||||
|
||||
dustTexture = new Texture(renderer, asset->get("title_dust.png"));
|
||||
coffeeTexture = new Texture(renderer, asset->get("title_coffee.png"));
|
||||
crisisTexture = new Texture(renderer, asset->get("title_crisis.png"));
|
||||
|
||||
coffeeBitmap = new SmartSprite(coffeeTexture, renderer);
|
||||
crisisBitmap = new SmartSprite(crisisTexture, renderer);
|
||||
dustBitmapL = new AnimatedSprite(dustTexture, renderer, asset->get("title_dust.ani"));
|
||||
dustBitmapR = new AnimatedSprite(dustTexture, renderer, asset->get("title_dust.ani"));
|
||||
|
||||
text1 = new Text(asset->get("smb2.png"), asset->get("smb2.txt"), renderer);
|
||||
text2 = new Text(asset->get("8bithud.png"), asset->get("8bithud.txt"), renderer);
|
||||
|
||||
@@ -37,8 +28,8 @@ Title::Title(SDL_Renderer *renderer, Screen *screen, Input *input, Asset *asset,
|
||||
|
||||
tiledbg = new Tiledbg(renderer, screen, asset, {0, 0, GAMECANVAS_WIDTH, GAMECANVAS_HEIGHT});
|
||||
|
||||
// Sonidos
|
||||
crashSound = JA_LoadSound(asset->get("title.wav").c_str());
|
||||
gameLogo = new GameLogo(renderer, screen, asset, GAMECANVAS_CENTER_X, GAMECANVAS_FIRST_QUARTER_Y + 20);
|
||||
gameLogo->enable();
|
||||
|
||||
// Musicas
|
||||
titleMusic = JA_LoadMusic(asset->get("title.ogg").c_str());
|
||||
@@ -54,27 +45,13 @@ Title::~Title()
|
||||
delete eventHandler;
|
||||
delete fade;
|
||||
|
||||
dustTexture->unload();
|
||||
delete dustTexture;
|
||||
|
||||
coffeeTexture->unload();
|
||||
delete coffeeTexture;
|
||||
|
||||
crisisTexture->unload();
|
||||
delete crisisTexture;
|
||||
|
||||
delete coffeeBitmap;
|
||||
delete crisisBitmap;
|
||||
delete dustBitmapL;
|
||||
delete dustBitmapR;
|
||||
|
||||
delete text1;
|
||||
delete text2;
|
||||
|
||||
delete backgroundObj;
|
||||
delete tiledbg;
|
||||
delete gameLogo;
|
||||
|
||||
JA_DeleteSound(crashSound);
|
||||
JA_DeleteMusic(titleMusic);
|
||||
}
|
||||
|
||||
@@ -84,7 +61,6 @@ void Title::init()
|
||||
// Inicializa variables
|
||||
section->subsection = SUBSECTION_TITLE_1;
|
||||
counter = TITLE_COUNTER;
|
||||
menuVisible = false;
|
||||
nextSection.name = SECTION_PROG_GAME;
|
||||
postFade = 0;
|
||||
ticks = 0;
|
||||
@@ -121,53 +97,6 @@ void Title::init()
|
||||
options->input[1].name = availableInputDevices[deviceIndex[1]].name;
|
||||
options->input[1].deviceType = availableInputDevices[deviceIndex[1]].deviceType;
|
||||
}
|
||||
|
||||
// Inicializa el bitmap de 'Coffee'
|
||||
coffeeBitmap->init();
|
||||
coffeeBitmap->setPosX(45);
|
||||
coffeeBitmap->setPosY(11 - 200);
|
||||
coffeeBitmap->setWidth(167);
|
||||
coffeeBitmap->setHeight(46);
|
||||
coffeeBitmap->setVelX(0.0f);
|
||||
coffeeBitmap->setVelY(2.5f);
|
||||
coffeeBitmap->setAccelX(0.0f);
|
||||
coffeeBitmap->setAccelY(0.1f);
|
||||
coffeeBitmap->setSpriteClip(0, 0, 167, 46);
|
||||
coffeeBitmap->setEnabled(true);
|
||||
coffeeBitmap->setEnabledCounter(0);
|
||||
coffeeBitmap->setDestX(45);
|
||||
coffeeBitmap->setDestY(11);
|
||||
|
||||
// Inicializa el bitmap de 'Crisis'
|
||||
crisisBitmap->init();
|
||||
crisisBitmap->setPosX(60);
|
||||
crisisBitmap->setPosY(57 + 200);
|
||||
crisisBitmap->setWidth(137);
|
||||
crisisBitmap->setHeight(46);
|
||||
crisisBitmap->setVelX(0.0f);
|
||||
crisisBitmap->setVelY(-2.5f);
|
||||
crisisBitmap->setAccelX(0.0f);
|
||||
crisisBitmap->setAccelY(-0.1f);
|
||||
crisisBitmap->setSpriteClip(0, 0, 137, 46);
|
||||
crisisBitmap->setEnabled(true);
|
||||
crisisBitmap->setEnabledCounter(0);
|
||||
crisisBitmap->setDestX(60);
|
||||
crisisBitmap->setDestY(57);
|
||||
|
||||
// Inicializa el bitmap de 'DustRight'
|
||||
dustBitmapR->resetAnimation();
|
||||
dustBitmapR->setPosX(218);
|
||||
dustBitmapR->setPosY(47);
|
||||
dustBitmapR->setWidth(16);
|
||||
dustBitmapR->setHeight(16);
|
||||
dustBitmapR->setFlip(SDL_FLIP_HORIZONTAL);
|
||||
|
||||
// Inicializa el bitmap de 'DustLeft'
|
||||
dustBitmapL->resetAnimation();
|
||||
dustBitmapL->setPosX(33);
|
||||
dustBitmapL->setPosY(47);
|
||||
dustBitmapL->setWidth(16);
|
||||
dustBitmapL->setHeight(16);
|
||||
}
|
||||
|
||||
// Actualiza las variables del objeto
|
||||
@@ -182,55 +111,18 @@ void Title::update()
|
||||
// Actualiza el objeto 'background'
|
||||
backgroundObj->update();
|
||||
|
||||
// Se realizan diferentes cosas en funcion de la subsección actual
|
||||
switch (section->subsection)
|
||||
// Sección 1 - Titulo animandose
|
||||
if (section->subsection == SUBSECTION_TITLE_1)
|
||||
{
|
||||
// Sección 1 - Titulo desplazandose
|
||||
case SUBSECTION_TITLE_1:
|
||||
{
|
||||
// Actualiza los objetos
|
||||
coffeeBitmap->update();
|
||||
crisisBitmap->update();
|
||||
|
||||
// Si los objetos han llegado a su destino, cambiamos de Sección
|
||||
if (coffeeBitmap->hasFinished() && crisisBitmap->hasFinished())
|
||||
gameLogo->update();
|
||||
if (gameLogo->hasFinished())
|
||||
{
|
||||
section->subsection = SUBSECTION_TITLE_2;
|
||||
|
||||
// Pantallazo blanco
|
||||
screen->setFlash({0xFF, 0xFF, 0xFF}, 5);
|
||||
|
||||
// Reproduce el efecto sonoro
|
||||
JA_PlaySound(crashSound);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
// Sección 2 - Titulo vibrando
|
||||
case SUBSECTION_TITLE_2:
|
||||
{
|
||||
// Agita el logo
|
||||
static const int v[] = {-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, 0};
|
||||
static const int a = coffeeBitmap->getPosX();
|
||||
static const int b = crisisBitmap->getPosX();
|
||||
static int step = 0;
|
||||
|
||||
coffeeBitmap->setPosX(a + v[step / 3]);
|
||||
crisisBitmap->setPosX(b + v[step / 3]);
|
||||
dustBitmapR->update();
|
||||
dustBitmapL->update();
|
||||
|
||||
step++;
|
||||
if (step == 33)
|
||||
{
|
||||
section->subsection = SUBSECTION_TITLE_3;
|
||||
step = 0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
// Sección 3 - La pantalla de titulo con el menú y la música
|
||||
case SUBSECTION_TITLE_3:
|
||||
// Sección 2 - La pantalla con el titulo, el fondo animado y la música
|
||||
else if (section->subsection == SUBSECTION_TITLE_2)
|
||||
{
|
||||
if (counter > 0)
|
||||
{
|
||||
@@ -242,9 +134,11 @@ void Title::update()
|
||||
JA_PlayMusic(titleMusic);
|
||||
}
|
||||
|
||||
// Actualiza los objetos
|
||||
dustBitmapR->update();
|
||||
dustBitmapL->update();
|
||||
// Actualiza el logo con el título del juego
|
||||
gameLogo->update();
|
||||
|
||||
// Actualiza el mosaico de fondo
|
||||
tiledbg->update();
|
||||
|
||||
// Actualiza la lógica del titulo
|
||||
fade->update();
|
||||
@@ -292,9 +186,6 @@ void Title::update()
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Actualiza el mosaico de fondo
|
||||
tiledbg->update();
|
||||
}
|
||||
else if (counter == 0)
|
||||
{
|
||||
@@ -327,12 +218,6 @@ void Title::update()
|
||||
demo = true;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -349,15 +234,10 @@ void Title::render()
|
||||
tiledbg->render();
|
||||
// backgroundObj->render();
|
||||
|
||||
// Dibuja el logo
|
||||
coffeeBitmap->render();
|
||||
crisisBitmap->render();
|
||||
// Dinuja el logo con el título del juego
|
||||
gameLogo->render();
|
||||
|
||||
// Dibuja el polvillo del logo
|
||||
dustBitmapR->render();
|
||||
dustBitmapL->render();
|
||||
|
||||
if (section->subsection == SUBSECTION_TITLE_3)
|
||||
if (section->subsection == SUBSECTION_TITLE_2)
|
||||
{
|
||||
// PRESS ANY KEY!
|
||||
if (counter % 50 > 14)
|
||||
@@ -582,8 +462,6 @@ void Title::checkInputDevices()
|
||||
// Recarga las texturas
|
||||
void Title::reLoadTextures()
|
||||
{
|
||||
dustTexture->reLoad();
|
||||
coffeeTexture->reLoad();
|
||||
crisisTexture->reLoad();
|
||||
gameLogo->reLoad();
|
||||
tiledbg->reLoad();
|
||||
}
|
||||
Reference in New Issue
Block a user