Limpieza de código en la lógica y dibujado del titulo
This commit is contained in:
129
source/title.cpp
129
source/title.cpp
@@ -190,9 +190,6 @@ void Title::init()
|
|||||||
// Actualiza las variables del objeto
|
// Actualiza las variables del objeto
|
||||||
void Title::update()
|
void Title::update()
|
||||||
{
|
{
|
||||||
// Comprueba las entradas
|
|
||||||
checkInput();
|
|
||||||
|
|
||||||
// Calcula la lógica de los objetos
|
// Calcula la lógica de los objetos
|
||||||
if (SDL_GetTicks() - ticks > ticksSpeed)
|
if (SDL_GetTicks() - ticks > ticksSpeed)
|
||||||
{
|
{
|
||||||
@@ -229,7 +226,7 @@ void Title::update()
|
|||||||
// Sección 2 - Titulo vibrando
|
// Sección 2 - Titulo vibrando
|
||||||
case SUBSECTION_TITLE_2:
|
case SUBSECTION_TITLE_2:
|
||||||
{
|
{
|
||||||
// Agita la pantalla
|
// 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 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 a = coffeeBitmap->getPosX();
|
||||||
static const int b = crisisBitmap->getPosX();
|
static const int b = crisisBitmap->getPosX();
|
||||||
@@ -241,10 +238,10 @@ void Title::update()
|
|||||||
dustBitmapL->update();
|
dustBitmapL->update();
|
||||||
|
|
||||||
step++;
|
step++;
|
||||||
|
|
||||||
if (step == 33)
|
if (step == 33)
|
||||||
{
|
{
|
||||||
section->subsection = SUBSECTION_TITLE_3;
|
section->subsection = SUBSECTION_TITLE_3;
|
||||||
|
step = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -262,6 +259,7 @@ void Title::update()
|
|||||||
JA_PlayMusic(titleMusic);
|
JA_PlayMusic(titleMusic);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Actualiza los objetos
|
||||||
dustBitmapR->update();
|
dustBitmapR->update();
|
||||||
dustBitmapL->update();
|
dustBitmapL->update();
|
||||||
|
|
||||||
@@ -358,92 +356,38 @@ void Title::update()
|
|||||||
// Dibuja el objeto en pantalla
|
// Dibuja el objeto en pantalla
|
||||||
void Title::render()
|
void Title::render()
|
||||||
{
|
{
|
||||||
switch (section->subsection)
|
// Prepara para empezar a dibujar en la textura de juego
|
||||||
|
screen->start();
|
||||||
|
|
||||||
|
// Limpia la pantalla
|
||||||
|
screen->clean(bgColor);
|
||||||
|
|
||||||
|
// Dibuja el tileado de fondo
|
||||||
|
SDL_RenderCopy(renderer, background, &backgroundWindow, nullptr);
|
||||||
|
// backgroundObj->render();
|
||||||
|
|
||||||
|
// Dibuja el logo
|
||||||
|
coffeeBitmap->render();
|
||||||
|
crisisBitmap->render();
|
||||||
|
|
||||||
|
// Dibuja el polvillo del logo
|
||||||
|
dustBitmapR->render();
|
||||||
|
dustBitmapL->render();
|
||||||
|
|
||||||
|
if (section->subsection == SUBSECTION_TITLE_3)
|
||||||
{
|
{
|
||||||
// Sección 1 - Titulo desplazandose
|
|
||||||
case SUBSECTION_TITLE_1:
|
|
||||||
{
|
|
||||||
// Prepara para empezar a dibujar en la textura de juego
|
|
||||||
screen->start();
|
|
||||||
|
|
||||||
// Limpia la pantalla
|
|
||||||
screen->clean(bgColor);
|
|
||||||
|
|
||||||
// Dibuja el tileado de fondo
|
|
||||||
// SDL_RenderCopy(renderer, background, &backgroundWindow, nullptr);
|
|
||||||
backgroundObj->render();
|
|
||||||
|
|
||||||
// Dibuja los objetos
|
|
||||||
coffeeBitmap->render();
|
|
||||||
crisisBitmap->render();
|
|
||||||
|
|
||||||
// Vuelca el contenido del renderizador en pantalla
|
|
||||||
screen->blit();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
// Sección 2 - Titulo vibrando
|
|
||||||
case SUBSECTION_TITLE_2:
|
|
||||||
{
|
|
||||||
// Prepara para empezar a dibujar en la textura de juego
|
|
||||||
screen->start();
|
|
||||||
|
|
||||||
// Limpia la pantalla
|
|
||||||
screen->clean(bgColor);
|
|
||||||
|
|
||||||
// Dibuja el tileado de fondo
|
|
||||||
// SDL_RenderCopy(renderer, background, &backgroundWindow, nullptr);
|
|
||||||
backgroundObj->render();
|
|
||||||
|
|
||||||
// Dibuja los objetos
|
|
||||||
coffeeBitmap->render();
|
|
||||||
crisisBitmap->render();
|
|
||||||
|
|
||||||
dustBitmapR->render();
|
|
||||||
dustBitmapL->render();
|
|
||||||
|
|
||||||
// Vuelca el contenido del renderizador en pantalla
|
|
||||||
screen->blit();
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
// Sección 3 - La pantalla de titulo con el menú y la música
|
|
||||||
case SUBSECTION_TITLE_3:
|
|
||||||
{ // Prepara para empezar a dibujar en la textura de juego
|
|
||||||
screen->start();
|
|
||||||
|
|
||||||
// Limpia la pantalla
|
|
||||||
screen->clean(bgColor);
|
|
||||||
|
|
||||||
// Dibuja el tileado de fondo
|
|
||||||
// SDL_RenderCopy(renderer, background, &backgroundWindow, nullptr);
|
|
||||||
backgroundObj->render();
|
|
||||||
|
|
||||||
coffeeBitmap->render();
|
|
||||||
crisisBitmap->render();
|
|
||||||
|
|
||||||
// Dibuja el polvillo del título
|
|
||||||
dustBitmapR->render();
|
|
||||||
dustBitmapL->render();
|
|
||||||
|
|
||||||
// PRESS ANY KEY!
|
// PRESS ANY KEY!
|
||||||
if (counter % 50 > 14)
|
if (counter % 50 > 14)
|
||||||
{
|
{
|
||||||
text1->writeDX(TXT_CENTER | TXT_SHADOW, GAMECANVAS_CENTER_X, GAMECANVAS_THIRD_QUARTER_Y + BLOCK, lang->getText(23), 1, noColor, 1, shdwTxtColor);
|
text1->writeDX(TXT_CENTER | TXT_SHADOW, GAMECANVAS_CENTER_X, GAMECANVAS_THIRD_QUARTER_Y + BLOCK, lang->getText(23), 1, noColor, 1, shdwTxtColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fade
|
|
||||||
fade->render();
|
|
||||||
|
|
||||||
// Vuelca el contenido del renderizador en pantalla
|
|
||||||
screen->blit();
|
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
// Fade
|
||||||
break;
|
fade->render();
|
||||||
}
|
|
||||||
|
// Vuelca el contenido del renderizador en pantalla
|
||||||
|
screen->blit();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Comprueba los eventos
|
// Comprueba los eventos
|
||||||
@@ -463,18 +407,6 @@ void Title::checkEvents()
|
|||||||
{
|
{
|
||||||
reLoadTextures();
|
reLoadTextures();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (section->subsection == SUBSECTION_TITLE_3)
|
|
||||||
{ // Si se pulsa alguna tecla durante la tercera sección del titulo
|
|
||||||
if ((eventHandler->type == SDL_KEYUP) || (eventHandler->type == SDL_JOYBUTTONUP))
|
|
||||||
{
|
|
||||||
// Muestra el menu
|
|
||||||
menuVisible = true;
|
|
||||||
|
|
||||||
// Reinicia el contador
|
|
||||||
counter = TITLE_COUNTER;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -500,6 +432,12 @@ void Title::checkInput()
|
|||||||
{
|
{
|
||||||
screen->incWindowSize();
|
screen->incWindowSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
else if (input->checkInput(input_accept, REPEAT_FALSE))
|
||||||
|
{
|
||||||
|
fade->activateFade();
|
||||||
|
postFade = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actualiza el tileado de fondo
|
// Actualiza el tileado de fondo
|
||||||
@@ -544,6 +482,7 @@ void Title::run()
|
|||||||
{
|
{
|
||||||
while (section->name == SECTION_PROG_TITLE)
|
while (section->name == SECTION_PROG_TITLE)
|
||||||
{
|
{
|
||||||
|
checkInput();
|
||||||
update();
|
update();
|
||||||
checkEvents();
|
checkEvents();
|
||||||
render();
|
render();
|
||||||
|
|||||||
@@ -48,9 +48,9 @@ private:
|
|||||||
section_t *section; // Indicador para el bucle del titulo
|
section_t *section; // Indicador para el bucle del titulo
|
||||||
Background *backgroundObj; // Objeto para dibujar el fondo del juego
|
Background *backgroundObj; // Objeto para dibujar el fondo del juego
|
||||||
|
|
||||||
Texture *dustTexture; // Textura con los graficos del polvo
|
Texture *dustTexture; // Textura con los graficos del polvo
|
||||||
Texture *coffeeTexture; // Textura con los graficos de la palabra coffee
|
Texture *coffeeTexture; // Textura con los graficos de la palabra coffee
|
||||||
Texture *crisisTexture; // Textura con los graficos de la plabra crisis
|
Texture *crisisTexture; // Textura con los graficos de la plabra crisis
|
||||||
|
|
||||||
SDL_Rect backgroundWindow; // Ventana visible para la textura de fondo del titulo
|
SDL_Rect backgroundWindow; // Ventana visible para la textura de fondo del titulo
|
||||||
SDL_Texture *background; // Textura dibujar el fondo del titulo
|
SDL_Texture *background; // Textura dibujar el fondo del titulo
|
||||||
|
|||||||
3
todo.txt
3
todo.txt
@@ -6,4 +6,5 @@
|
|||||||
[] Hacer el marcador transparente
|
[] Hacer el marcador transparente
|
||||||
[] Valorar la opcion de que write devuelva texturas con el texto en lugar de pintar letra a letra
|
[] Valorar la opcion de que write devuelva texturas con el texto en lugar de pintar letra a letra
|
||||||
[] Arreglar los anclajes en la pantalla de game over
|
[] Arreglar los anclajes en la pantalla de game over
|
||||||
[] Al poner pausa, que se sigan moviendo las nubes
|
[] Al poner pausa, que se sigan moviendo las nubes
|
||||||
|
[] Revisar la clase Fade
|
||||||
Reference in New Issue
Block a user