Cambiada la lógica para el carrusel de secciones del modo demo

This commit is contained in:
2024-06-28 11:52:18 +02:00
parent 2650a64c80
commit 85a24e0100
13 changed files with 114 additions and 226 deletions

View File

@@ -1,8 +1,6 @@
#include "instructions.h"
#include <iostream>
const Uint8 SELF = 0;
// Constructor
Instructions::Instructions(SDL_Renderer *renderer, Screen *screen, Asset *asset, Input *input, Lang *lang, param_t *param, section_t *section)
{
@@ -41,13 +39,10 @@ Instructions::Instructions(SDL_Renderer *renderer, Screen *screen, Asset *asset,
// Crea un backbuffer para el renderizador
backbuffer = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, param->gameWidth, param->gameHeight);
if (backbuffer == nullptr)
{
std::cout << "Error: textTexture could not be created!\nSDL Error: " << SDL_GetError() << std::endl;
}
SDL_SetTextureBlendMode(backbuffer, SDL_BLENDMODE_BLEND);
// Inicializa variables
section->name = SELF;
section->name = SECTION_PROG_INSTRUCTIONS;
ticks = 0;
ticksSpeed = 15;
manualQuit = false;
@@ -84,25 +79,12 @@ void Instructions::update()
// Actualiza el contador de ticks
ticks = SDL_GetTicks();
if (mode == m_auto)
{ // Modo automático
counter++;
counter++;
if (counter == counterEnd)
{
section->name = SECTION_PROG_TITLE;
section->subsection = SUBSECTION_TITLE_1;
}
}
else
{ // Modo manual
++counter %= 60000;
if (manualQuit)
{
section->name = SECTION_PROG_TITLE;
section->subsection = SUBSECTION_TITLE_2;
}
if (counter == counterEnd)
{
section->name = SECTION_PROG_TITLE;
section->subsection = SUBSECTION_TITLE_1;
}
}
}
@@ -141,11 +123,6 @@ void Instructions::render()
text->writeShadowed(84, 140, lang->getText(20), shdwTxtColor);
text->writeShadowed(84, 156, lang->getText(21), shdwTxtColor);
if ((mode == m_manual) && (counter % 50 > 14))
{
text->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, GAMECANVAS_CENTER_X, param->gameHeight - 12, lang->getText(22), 1, orangeColor, 1, shdwTxtColor);
}
// Disquito
sprite->setTexture(itemTextures[0]);
sprite->setPos(destRect1);
@@ -191,14 +168,7 @@ void Instructions::render()
screen->clean(bgColor);
// Establece la ventana del backbuffer
if (mode == m_auto)
{
window.y = std::max(8, param->gameHeight - counter + 100);
}
else
{
window.y = 0;
}
window.y = std::max(8, param->gameHeight - counter + 100);
// Copia el backbuffer al renderizador
SDL_RenderCopy(renderer, backbuffer, nullptr, &window);
@@ -247,28 +217,16 @@ void Instructions::checkInput()
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))
{
if (mode == m_auto)
{
JA_StopMusic();
section->name = SECTION_PROG_TITLE;
section->subsection = SUBSECTION_TITLE_1;
}
else
{
if (counter > 30)
{
manualQuit = true;
}
}
}
}
// Bucle para la pantalla de instrucciones
void Instructions::run(mode_e mode)
void Instructions::run()
{
this->mode = mode;
while (section->name == SELF)
while (section->name == SECTION_PROG_INSTRUCTIONS)
{
update();
checkEvents();