treball en curs: correccions de tidy

This commit is contained in:
2026-05-16 14:04:59 +02:00
parent 48af959814
commit be18f51735
31 changed files with 1741 additions and 1966 deletions
+113 -113
View File
@@ -21,50 +21,50 @@
// Constructor
Instructions::Instructions(SDL_Renderer *renderer, Section *section) {
// Copia los punteros
this->renderer = renderer;
this->section = section;
this->renderer_ = renderer;
this->section_ = section;
// Texturas (handles compartidos de Resource)
Resource *R = Resource::get();
itemTextures.push_back(R->getTexture("item_points1_disk.png"));
itemTextures.push_back(R->getTexture("item_points2_gavina.png"));
itemTextures.push_back(R->getTexture("item_points3_pacmar.png"));
itemTextures.push_back(R->getTexture("item_clock.png"));
itemTextures.push_back(R->getTexture("item_coffee.png"));
itemTextures.push_back(R->getTexture("item_coffee_machine.png"));
Resource *resource = Resource::get();
item_textures_.push_back(resource->getTexture("item_points1_disk.png"));
item_textures_.push_back(resource->getTexture("item_points2_gavina.png"));
item_textures_.push_back(resource->getTexture("item_points3_pacmar.png"));
item_textures_.push_back(resource->getTexture("item_clock.png"));
item_textures_.push_back(resource->getTexture("item_coffee.png"));
item_textures_.push_back(resource->getTexture("item_coffee_machine.png"));
eventHandler = new SDL_Event();
event_handler_ = new SDL_Event();
sprite = new Sprite(0, 0, 16, 16, itemTextures[0], renderer);
text = R->getText("smb2");
sprite_ = new Sprite(0, 0, 16, 16, item_textures_[0], renderer);
text_ = resource->getText("smb2");
// Crea un backbuffer para el renderizador
backbuffer = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, GAMECANVAS_WIDTH, GAMECANVAS_HEIGHT);
if (backbuffer != nullptr) {
SDL_SetTextureScaleMode(backbuffer, Texture::currentScaleMode);
backbuffer_ = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, GAMECANVAS_WIDTH, GAMECANVAS_HEIGHT);
if (backbuffer_ != nullptr) {
SDL_SetTextureScaleMode(backbuffer_, Texture::currentScaleMode);
} else {
std::cout << "Error: textTexture could not be created!\nSDL Error: " << SDL_GetError() << '\n';
}
// Inicializa variables
ticks = 0;
ticksSpeed = 15;
manualQuit = false;
counter = 0;
counterEnd = 600;
finished = false;
quitRequested = false;
ticks_ = 0;
ticks_speed_ = 15;
manual_quit_ = false;
counter_ = 0;
counter_end_ = 600;
finished_ = false;
quit_requested_ = false;
}
// Destructor
Instructions::~Instructions() {
// itemTextures y text son propiedad de Resource — no liberar.
itemTextures.clear();
item_textures_.clear();
delete sprite;
delete eventHandler;
delete sprite_;
delete event_handler_;
SDL_DestroyTexture(backbuffer);
SDL_DestroyTexture(backbuffer_);
}
// Actualiza las variables
@@ -77,21 +77,21 @@ void Instructions::update() {
checkInput();
// Actualiza las variables
if (SDL_GetTicks() - ticks > ticksSpeed) {
if (SDL_GetTicks() - ticks_ > ticks_speed_) {
// Actualiza el contador de ticks
ticks = SDL_GetTicks();
ticks_ = SDL_GetTicks();
if (mode == m_auto) { // Modo automático
counter++;
if (mode_ == Mode::AUTO) { // Modo automático
counter_++;
if (counter == counterEnd) {
finished = true;
if (counter_ == counter_end_) {
finished_ = true;
}
} else { // Modo manual
++counter %= 60000;
++counter_ %= 60000;
if (manualQuit) {
finished = true;
if (manual_quit_) {
finished_ = true;
}
}
}
@@ -101,76 +101,76 @@ void Instructions::update() {
void Instructions::render() {
// Pinta en pantalla
SDL_Rect window = {0, 0, GAMECANVAS_WIDTH, GAMECANVAS_HEIGHT};
SDL_Rect srcRect = {0, 0, 16, 16};
SDL_Rect src_rect = {0, 0, 16, 16};
const Color orangeColor = {0xFF, 0x7A, 0x00};
const Color ORANGE_COLOR = {0xFF, 0x7A, 0x00};
const SDL_Rect destRect1 = {60, 88 + (16 * 0), 16, 16}; // Disquito
const SDL_Rect destRect2 = {60, 88 + (16 * 1), 16, 16}; // Gavineixon
const SDL_Rect destRect3 = {60, 88 + (16 * 2), 16, 16}; // Pacmar
const SDL_Rect destRect4 = {60, 88 + (16 * 3), 16, 16}; // Time Stopper
const SDL_Rect destRect5 = {60, 88 + (16 * 4), 16, 16}; // Coffee
const SDL_Rect DEST_RECT1 = {60, 88 + (16 * 0), 16, 16}; // Disquito
const SDL_Rect DEST_RECT2 = {60, 88 + (16 * 1), 16, 16}; // Gavineixon
const SDL_Rect DEST_RECT3 = {60, 88 + (16 * 2), 16, 16}; // Pacmar
const SDL_Rect DEST_RECT4 = {60, 88 + (16 * 3), 16, 16}; // Time Stopper
const SDL_Rect DEST_RECT5 = {60, 88 + (16 * 4), 16, 16}; // Coffee
// Pinta en el backbuffer el texto y los sprites
SDL_SetRenderTarget(renderer, backbuffer);
SDL_SetRenderDrawColor(renderer, bgColor.r, bgColor.g, bgColor.b, 255);
SDL_RenderClear(renderer);
SDL_SetRenderTarget(renderer_, backbuffer_);
SDL_SetRenderDrawColor(renderer_, bgColor.r, bgColor.g, bgColor.b, 255);
SDL_RenderClear(renderer_);
// Escribe el texto
text->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, GAMECANVAS_CENTER_X, 8, Lang::get()->getText(11), 1, orangeColor, 1, shdwTxtColor);
text->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, GAMECANVAS_CENTER_X, 24, Lang::get()->getText(12), 1, noColor, 1, shdwTxtColor);
text->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, GAMECANVAS_CENTER_X, 34, Lang::get()->getText(13), 1, noColor, 1, shdwTxtColor);
text->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, GAMECANVAS_CENTER_X, 48, Lang::get()->getText(14), 1, noColor, 1, shdwTxtColor);
text->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, GAMECANVAS_CENTER_X, 58, Lang::get()->getText(15), 1, noColor, 1, shdwTxtColor);
text->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, GAMECANVAS_CENTER_X, 75, Lang::get()->getText(16), 1, orangeColor, 1, shdwTxtColor);
text_->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, GAMECANVAS_CENTER_X, 8, Lang::get()->getText(11), 1, ORANGE_COLOR, 1, shdwTxtColor);
text_->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, GAMECANVAS_CENTER_X, 24, Lang::get()->getText(12), 1, noColor, 1, shdwTxtColor);
text_->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, GAMECANVAS_CENTER_X, 34, Lang::get()->getText(13), 1, noColor, 1, shdwTxtColor);
text_->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, GAMECANVAS_CENTER_X, 48, Lang::get()->getText(14), 1, noColor, 1, shdwTxtColor);
text_->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, GAMECANVAS_CENTER_X, 58, Lang::get()->getText(15), 1, noColor, 1, shdwTxtColor);
text_->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, GAMECANVAS_CENTER_X, 75, Lang::get()->getText(16), 1, ORANGE_COLOR, 1, shdwTxtColor);
text->writeShadowed(84, 92, Lang::get()->getText(17), shdwTxtColor);
text->writeShadowed(84, 108, Lang::get()->getText(18), shdwTxtColor);
text->writeShadowed(84, 124, Lang::get()->getText(19), shdwTxtColor);
text->writeShadowed(84, 140, Lang::get()->getText(20), shdwTxtColor);
text->writeShadowed(84, 156, Lang::get()->getText(21), shdwTxtColor);
text_->writeShadowed(84, 92, Lang::get()->getText(17), shdwTxtColor);
text_->writeShadowed(84, 108, Lang::get()->getText(18), shdwTxtColor);
text_->writeShadowed(84, 124, Lang::get()->getText(19), shdwTxtColor);
text_->writeShadowed(84, 140, Lang::get()->getText(20), shdwTxtColor);
text_->writeShadowed(84, 156, Lang::get()->getText(21), shdwTxtColor);
if ((mode == m_manual) && (counter % 50 > 14)) {
text->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, GAMECANVAS_CENTER_X, GAMECANVAS_HEIGHT - 12, Lang::get()->getText(22), 1, orangeColor, 1, shdwTxtColor);
if ((mode_ == Mode::MANUAL) && (counter_ % 50 > 14)) {
text_->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, GAMECANVAS_CENTER_X, GAMECANVAS_HEIGHT - 12, Lang::get()->getText(22), 1, ORANGE_COLOR, 1, shdwTxtColor);
}
// Disquito
sprite->setTexture(itemTextures[0]);
sprite->setPos(destRect1);
srcRect.y = 16 * (((counter + 12) / 36) % 2);
sprite->setSpriteClip(srcRect);
sprite->render();
sprite_->setTexture(item_textures_[0]);
sprite_->setPos(DEST_RECT1);
src_rect.y = 16 * (((counter_ + 12) / 36) % 2);
sprite_->setSpriteClip(src_rect);
sprite_->render();
// Gavineixon
sprite->setTexture(itemTextures[1]);
sprite->setPos(destRect2);
srcRect.y = 16 * (((counter + 9) / 36) % 2);
sprite->setSpriteClip(srcRect);
sprite->render();
sprite_->setTexture(item_textures_[1]);
sprite_->setPos(DEST_RECT2);
src_rect.y = 16 * (((counter_ + 9) / 36) % 2);
sprite_->setSpriteClip(src_rect);
sprite_->render();
// Pacmar
sprite->setTexture(itemTextures[2]);
sprite->setPos(destRect3);
srcRect.y = 16 * (((counter + 6) / 36) % 2);
sprite->setSpriteClip(srcRect);
sprite->render();
sprite_->setTexture(item_textures_[2]);
sprite_->setPos(DEST_RECT3);
src_rect.y = 16 * (((counter_ + 6) / 36) % 2);
sprite_->setSpriteClip(src_rect);
sprite_->render();
// Time Stopper
sprite->setTexture(itemTextures[3]);
sprite->setPos(destRect4);
srcRect.y = 16 * (((counter + 3) / 36) % 2);
sprite->setSpriteClip(srcRect);
sprite->render();
sprite_->setTexture(item_textures_[3]);
sprite_->setPos(DEST_RECT4);
src_rect.y = 16 * (((counter_ + 3) / 36) % 2);
sprite_->setSpriteClip(src_rect);
sprite_->render();
// Coffee
sprite->setTexture(itemTextures[4]);
sprite->setPos(destRect5);
srcRect.y = 16 * (((counter + 0) / 36) % 2);
sprite->setSpriteClip(srcRect);
sprite->render();
sprite_->setTexture(item_textures_[4]);
sprite_->setPos(DEST_RECT5);
src_rect.y = 16 * (((counter_ + 0) / 36) % 2);
sprite_->setSpriteClip(src_rect);
sprite_->render();
// Cambia el destino de renderizado
SDL_SetRenderTarget(renderer, nullptr);
SDL_SetRenderTarget(renderer_, nullptr);
// Prepara para empezar a dibujar en la textura de juego
Screen::get()->start();
@@ -179,15 +179,15 @@ void Instructions::render() {
Screen::get()->clean(bgColor);
// Establece la ventana del backbuffer
if (mode == m_auto) {
window.y = std::max(8, GAMECANVAS_HEIGHT - counter + 100);
if (mode_ == Mode::AUTO) {
window.y = std::max(8, GAMECANVAS_HEIGHT - counter_ + 100);
} else {
window.y = 0;
}
// Copia el backbuffer al renderizador
SDL_FRect fWindow = {(float)window.x, (float)window.y, (float)window.w, (float)window.h};
SDL_RenderTexture(renderer, backbuffer, nullptr, &fWindow);
SDL_FRect f_window = {(float)window.x, (float)window.y, (float)window.w, (float)window.h};
SDL_RenderTexture(renderer_, backbuffer_, nullptr, &f_window);
// Vuelca el contenido del renderizador en pantalla
Screen::get()->blit();
@@ -197,11 +197,11 @@ void Instructions::render() {
void Instructions::checkEvents() {
#ifndef __EMSCRIPTEN__
// Comprueba los eventos que hay en la cola
while (static_cast<int>(SDL_PollEvent(eventHandler)) != 0) {
while (static_cast<int>(SDL_PollEvent(event_handler_)) != 0) {
// Evento de salida de la aplicación
if (eventHandler->type == SDL_EVENT_QUIT) {
quitRequested = true;
finished = true;
if (event_handler_->type == SDL_EVENT_QUIT) {
quit_requested_ = true;
finished_ = true;
break;
}
}
@@ -212,59 +212,59 @@ void Instructions::checkEvents() {
void Instructions::checkInput() {
#ifndef __EMSCRIPTEN__
if (Input::get()->checkInput(input_exit, REPEAT_FALSE)) {
quitRequested = true;
finished = true;
quit_requested_ = true;
finished_ = true;
return;
}
#endif
if (GlobalInputs::handle()) { return; }
if (Input::get()->checkInput(input_pause, REPEAT_FALSE) || Input::get()->checkInput(input_accept, REPEAT_FALSE) || Input::get()->checkInput(input_fire_left, REPEAT_FALSE) || Input::get()->checkInput(input_fire_center, REPEAT_FALSE) || Input::get()->checkInput(input_fire_right, REPEAT_FALSE)) {
if (mode == m_auto) {
finished = true;
if (mode_ == Mode::AUTO) {
finished_ = true;
} else {
if (counter > 30) {
manualQuit = true;
if (counter_ > 30) {
manual_quit_ = true;
}
}
}
}
// Bucle para la pantalla de instrucciones (compatibilidad)
void Instructions::run(InstructionsMode mode) {
void Instructions::run(Mode mode) {
start(mode);
while (!finished) {
while (!finished_) {
update();
checkEvents();
render();
}
// Aplica los cambios de sección según el resultado
if (quitRequested) {
section->name = SECTION_PROG_QUIT;
if (quit_requested_) {
section_->name = SECTION_PROG_QUIT;
} else {
section->name = SECTION_PROG_TITLE;
section->subsection = (mode == m_auto) ? SUBSECTION_TITLE_1 : SUBSECTION_TITLE_3;
section_->name = SECTION_PROG_TITLE;
section_->subsection = (mode == Mode::AUTO) ? SUBSECTION_TITLE_1 : SUBSECTION_TITLE_3;
}
}
// Inicia las instrucciones (sin bucle)
void Instructions::start(InstructionsMode mode) {
this->mode = mode;
finished = false;
quitRequested = false;
manualQuit = false;
counter = 0;
ticks = 0;
void Instructions::start(Mode mode) {
mode_ = mode;
finished_ = false;
quit_requested_ = false;
manual_quit_ = false;
counter_ = 0;
ticks_ = 0;
}
// Indica si las instrucciones han terminado
auto Instructions::hasFinished() const -> bool {
return finished;
return finished_;
}
// Indica si se ha solicitado salir de la aplicación
auto Instructions::isQuitRequested() const -> bool {
return quitRequested;
return quit_requested_;
}
+33 -49
View File
@@ -9,64 +9,48 @@ class Text;
class Texture;
struct Section;
enum InstructionsMode : std::uint8_t {
m_manual,
m_auto
};
// Clase Instructions
class Instructions {
private:
// Objetos y punteros
SDL_Renderer *renderer; // El renderizador de la ventana
std::vector<Texture *> itemTextures; // Vector con las texturas de los items
SDL_Event *eventHandler; // Manejador de eventos
SDL_Texture *backbuffer; // Textura para usar como backbuffer
Sprite *sprite; // Sprite con la textura de las instrucciones
Text *text; // Objeto para escribir texto
Section *section; // Estado del bucle principal para saber si continua o se sale
// Variables
Uint16 counter; // Contador
Uint16 counterEnd; // Valor final para el contador
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
bool manualQuit; // Indica si se quiere salir del modo manual
InstructionsMode mode{m_auto}; // Modo en el que se van a ejecutar las instrucciones
bool finished; // Indica si las instrucciones han terminado
bool quitRequested; // Indica si se ha solicitado salir de la aplicación
// Comprueba las entradas
void checkInput();
public:
// Constructor
Instructions(SDL_Renderer *renderer, Section *section);
enum class Mode : std::uint8_t {
MANUAL,
AUTO
};
// Destructor
~Instructions();
Instructions(SDL_Renderer *renderer, Section *section); // Constructor
~Instructions(); // Destructor
Instructions(const Instructions &) = delete;
auto operator=(const Instructions &) -> Instructions & = delete;
// Bucle principal
void run(InstructionsMode mode);
void run(Mode mode); // Bucle principal
void start(Mode mode); // Inicia las instrucciones (sin bucle)
void update(); // Actualiza las variables
void render(); // Pinta en pantalla
void checkEvents(); // Comprueba los eventos
// Inicia las instrucciones (sin bucle)
void start(InstructionsMode mode);
[[nodiscard]] auto hasFinished() const -> bool; // Indica si las instrucciones han terminado
[[nodiscard]] auto isQuitRequested() const -> bool; // Indica si se ha solicitado salir de la aplicación
// Actualiza las variables
void update();
private:
// Objetos y punteros
SDL_Renderer *renderer_; // El renderizador de la ventana
std::vector<Texture *> item_textures_; // Vector con las texturas de los items
SDL_Event *event_handler_; // Manejador de eventos
SDL_Texture *backbuffer_; // Textura para usar como backbuffer
Sprite *sprite_; // Sprite con la textura de las instrucciones
Text *text_; // Objeto para escribir texto
Section *section_; // Estado del bucle principal para saber si continua o se sale
// Pinta en pantalla
void render();
// Variables
Uint16 counter_; // Contador
Uint16 counter_end_; // Valor final para el contador
Uint32 ticks_; // Contador de ticks para ajustar la velocidad del programa
Uint32 ticks_speed_; // Velocidad a la que se repiten los bucles del programa
bool manual_quit_; // Indica si se quiere salir del modo manual
Mode mode_{Instructions::Mode::AUTO}; // Modo en el que se van a ejecutar las instrucciones
bool finished_; // Indica si las instrucciones han terminado
bool quit_requested_; // Indica si se ha solicitado salir de la aplicación
// Comprueba los eventos
void checkEvents();
// Indica si las instrucciones han terminado
[[nodiscard]] auto hasFinished() const -> bool;
// Indica si se ha solicitado salir de la aplicación
[[nodiscard]] auto isQuitRequested() const -> bool;
};
void checkInput(); // Comprueba las entradas
};
+229 -213
View File
@@ -10,8 +10,6 @@
#include "core/locale/lang.h" // for Lang
#include "core/rendering/screen.h" // for Screen
#include "core/rendering/smartsprite.h" // for SmartSprite
#include "core/rendering/text.h" // for Text
#include "core/rendering/texture.h" // for Texture
#include "core/rendering/writer.h" // for Writer
#include "core/resources/resource.h"
#include "game/defaults.hpp" // for GAMECANVAS_CENTER_X, GAMECANVAS_FIRST_QU...
@@ -20,148 +18,148 @@
// Constructor
Intro::Intro(SDL_Renderer *renderer, Section *section) {
// Copia los punteros
this->renderer = renderer;
this->section = section;
this->renderer_ = renderer;
this->section_ = section;
// Reserva memoria para los objetos
eventHandler = new SDL_Event();
texture = Resource::get()->getTexture("intro.png");
text = Resource::get()->getText("nokia");
music = Resource::get()->getMusic("intro.ogg");
event_handler_ = new SDL_Event();
texture_ = Resource::get()->getTexture("intro.png");
text_ = Resource::get()->getText("nokia");
music_ = Resource::get()->getMusic("intro.ogg");
// Inicializa variables
section->name = SECTION_PROG_INTRO;
section->subsection = 0;
ticks = 0;
ticksSpeed = 15;
scene = 1;
ticks_ = 0;
ticks_speed_ = 15;
scene_ = 1;
// Inicializa los bitmaps de la intro
const int totalBitmaps = 6;
for (int i = 0; i < totalBitmaps; ++i) {
auto *ss = new SmartSprite(texture, renderer);
const int TOTAL_BITMAPS = 6;
for (int i = 0; i < TOTAL_BITMAPS; ++i) {
auto *ss = new SmartSprite(texture_, renderer);
ss->setWidth(128);
ss->setHeight(96);
ss->setEnabledCounter(20);
ss->setDestX(GAMECANVAS_CENTER_X - 64);
ss->setDestY(GAMECANVAS_FIRST_QUARTER_Y - 24);
bitmaps.push_back(ss);
bitmaps_.push_back(ss);
}
bitmaps[0]->setPosX(-128);
bitmaps[0]->setPosY(GAMECANVAS_FIRST_QUARTER_Y - 24);
bitmaps[0]->setVelX(0.0F);
bitmaps[0]->setVelY(0.0F);
bitmaps[0]->setAccelX(0.6F);
bitmaps[0]->setAccelY(0.0F);
bitmaps[0]->setSpriteClip(0, 0, 128, 96);
bitmaps_[0]->setPosX(-128);
bitmaps_[0]->setPosY(GAMECANVAS_FIRST_QUARTER_Y - 24);
bitmaps_[0]->setVelX(0.0F);
bitmaps_[0]->setVelY(0.0F);
bitmaps_[0]->setAccelX(0.6F);
bitmaps_[0]->setAccelY(0.0F);
bitmaps_[0]->setSpriteClip(0, 0, 128, 96);
bitmaps[1]->setPosX(GAMECANVAS_WIDTH);
bitmaps[1]->setPosY(GAMECANVAS_FIRST_QUARTER_Y - 24);
bitmaps[1]->setVelX(-1.0F);
bitmaps[1]->setVelY(0.0F);
bitmaps[1]->setAccelX(-0.3F);
bitmaps[1]->setAccelY(0.0F);
bitmaps[1]->setSpriteClip(128, 0, 128, 96);
bitmaps_[1]->setPosX(GAMECANVAS_WIDTH);
bitmaps_[1]->setPosY(GAMECANVAS_FIRST_QUARTER_Y - 24);
bitmaps_[1]->setVelX(-1.0F);
bitmaps_[1]->setVelY(0.0F);
bitmaps_[1]->setAccelX(-0.3F);
bitmaps_[1]->setAccelY(0.0F);
bitmaps_[1]->setSpriteClip(128, 0, 128, 96);
bitmaps[2]->setPosX(GAMECANVAS_CENTER_X - 64);
bitmaps[2]->setPosY(-96);
bitmaps[2]->setVelX(0.0F);
bitmaps[2]->setVelY(3.0F);
bitmaps[2]->setAccelX(0.1F);
bitmaps[2]->setAccelY(0.3F);
bitmaps[2]->setSpriteClip(0, 96, 128, 96);
bitmaps[2]->setEnabledCounter(250);
bitmaps_[2]->setPosX(GAMECANVAS_CENTER_X - 64);
bitmaps_[2]->setPosY(-96);
bitmaps_[2]->setVelX(0.0F);
bitmaps_[2]->setVelY(3.0F);
bitmaps_[2]->setAccelX(0.1F);
bitmaps_[2]->setAccelY(0.3F);
bitmaps_[2]->setSpriteClip(0, 96, 128, 96);
bitmaps_[2]->setEnabledCounter(250);
bitmaps[3]->setPosX(GAMECANVAS_CENTER_X - 64);
bitmaps[3]->setPosY(GAMECANVAS_HEIGHT);
bitmaps[3]->setVelX(0.0F);
bitmaps[3]->setVelY(-0.7F);
bitmaps[3]->setAccelX(0.0F);
bitmaps[3]->setAccelY(0.0F);
bitmaps[3]->setSpriteClip(128, 96, 128, 96);
bitmaps_[3]->setPosX(GAMECANVAS_CENTER_X - 64);
bitmaps_[3]->setPosY(GAMECANVAS_HEIGHT);
bitmaps_[3]->setVelX(0.0F);
bitmaps_[3]->setVelY(-0.7F);
bitmaps_[3]->setAccelX(0.0F);
bitmaps_[3]->setAccelY(0.0F);
bitmaps_[3]->setSpriteClip(128, 96, 128, 96);
bitmaps[4]->setPosX(GAMECANVAS_CENTER_X - 64);
bitmaps[4]->setPosY(-96);
bitmaps[4]->setVelX(0.0F);
bitmaps[4]->setVelY(3.0F);
bitmaps[4]->setAccelX(0.1F);
bitmaps[4]->setAccelY(0.3F);
bitmaps[4]->setSpriteClip(0, 192, 128, 96);
bitmaps_[4]->setPosX(GAMECANVAS_CENTER_X - 64);
bitmaps_[4]->setPosY(-96);
bitmaps_[4]->setVelX(0.0F);
bitmaps_[4]->setVelY(3.0F);
bitmaps_[4]->setAccelX(0.1F);
bitmaps_[4]->setAccelY(0.3F);
bitmaps_[4]->setSpriteClip(0, 192, 128, 96);
bitmaps[5]->setPosX(GAMECANVAS_WIDTH);
bitmaps[5]->setPosY(GAMECANVAS_FIRST_QUARTER_Y - 24);
bitmaps[5]->setVelX(-0.7F);
bitmaps[5]->setVelY(0.0F);
bitmaps[5]->setAccelX(0.0F);
bitmaps[5]->setAccelY(0.0F);
bitmaps[5]->setSpriteClip(128, 192, 128, 96);
bitmaps_[5]->setPosX(GAMECANVAS_WIDTH);
bitmaps_[5]->setPosY(GAMECANVAS_FIRST_QUARTER_Y - 24);
bitmaps_[5]->setVelX(-0.7F);
bitmaps_[5]->setVelY(0.0F);
bitmaps_[5]->setAccelX(0.0F);
bitmaps_[5]->setAccelY(0.0F);
bitmaps_[5]->setSpriteClip(128, 192, 128, 96);
// Inicializa los textos de la intro
const int totalTexts = 9;
for (int i = 0; i < totalTexts; ++i) {
auto *w = new Writer(text);
const int TOTAL_TEXTS = 9;
for (int i = 0; i < TOTAL_TEXTS; ++i) {
auto *w = new Writer(text_);
w->setPosX(BLOCK * 0);
w->setPosY(GAMECANVAS_HEIGHT - (BLOCK * 6));
w->setKerning(-1);
w->setEnabled(false);
w->setEnabledCounter(180);
texts.push_back(w);
texts_.push_back(w);
}
// Un dia qualsevol de l'any 2000
texts[0]->setCaption(Lang::get()->getText(27));
texts[0]->setSpeed(8);
texts_[0]->setCaption(Lang::get()->getText(27));
texts_[0]->setSpeed(8);
// Tot esta tranquil a la UPV
texts[1]->setCaption(Lang::get()->getText(28));
texts[1]->setSpeed(8);
texts_[1]->setCaption(Lang::get()->getText(28));
texts_[1]->setSpeed(8);
// Fins que un desaprensiu...
texts[2]->setCaption(Lang::get()->getText(29));
texts[2]->setSpeed(12);
texts_[2]->setCaption(Lang::get()->getText(29));
texts_[2]->setSpeed(12);
// HEY! ME ANE A FERME UN CORTAET...
texts[3]->setCaption(Lang::get()->getText(30));
texts[3]->setSpeed(8);
texts_[3]->setCaption(Lang::get()->getText(30));
texts_[3]->setSpeed(8);
// UAAAAAAAAAAAAA!!!
texts[4]->setCaption(Lang::get()->getText(31));
texts[4]->setSpeed(1);
texts_[4]->setCaption(Lang::get()->getText(31));
texts_[4]->setSpeed(1);
// Espera un moment...
texts[5]->setCaption(Lang::get()->getText(32));
texts[5]->setSpeed(16);
texts_[5]->setCaption(Lang::get()->getText(32));
texts_[5]->setSpeed(16);
// Si resulta que no tinc solt!
texts[6]->setCaption(Lang::get()->getText(33));
texts[6]->setSpeed(2);
texts_[6]->setCaption(Lang::get()->getText(33));
texts_[6]->setSpeed(2);
// MERDA DE MAQUINA!
texts[7]->setCaption(Lang::get()->getText(34));
texts[7]->setSpeed(3);
texts_[7]->setCaption(Lang::get()->getText(34));
texts_[7]->setSpeed(3);
// Blop... blop... blop...
texts[8]->setCaption(Lang::get()->getText(35));
texts[8]->setSpeed(16);
texts_[8]->setCaption(Lang::get()->getText(35));
texts_[8]->setSpeed(16);
for (auto *t : texts) {
for (auto *t : texts_) {
t->center(GAMECANVAS_CENTER_X);
}
Audio::get()->playMusic(music, 0);
Audio::get()->playMusic(music_, 0);
}
// Destructor
Intro::~Intro() {
delete eventHandler;
delete event_handler_;
// texture, text, music son propiedad de Resource — no liberar aquí.
for (auto *bitmap : bitmaps) {
for (auto *bitmap : bitmaps_) {
delete bitmap;
}
for (auto *t : texts) {
for (auto *t : texts_) {
delete t;
}
}
@@ -170,7 +168,7 @@ Intro::~Intro() {
void Intro::checkInput() {
#ifndef __EMSCRIPTEN__
if (Input::get()->checkInput(input_exit, REPEAT_FALSE)) {
section->name = SECTION_PROG_QUIT;
section_->name = SECTION_PROG_QUIT;
return;
}
#endif
@@ -178,162 +176,180 @@ void Intro::checkInput() {
if (Input::get()->checkInput(input_pause, REPEAT_FALSE) || Input::get()->checkInput(input_accept, REPEAT_FALSE) || Input::get()->checkInput(input_fire_left, REPEAT_FALSE) || Input::get()->checkInput(input_fire_center, REPEAT_FALSE) || Input::get()->checkInput(input_fire_right, REPEAT_FALSE)) {
Audio::get()->stopMusic();
section->name = SECTION_PROG_TITLE;
section->subsection = SUBSECTION_TITLE_1;
section_->name = SECTION_PROG_TITLE;
section_->subsection = SUBSECTION_TITLE_1;
}
}
// Actualiza las escenas de la intro
void Intro::updateScenes() {
switch (scene) {
switch (scene_) {
case 1:
// Primera imagen - UPV
if (!bitmaps[0]->hasFinished()) {
bitmaps[0]->setEnabled(true);
}
// Primer texto de la primera imagen
if (bitmaps[0]->hasFinished() && !texts[0]->hasFinished()) {
texts[0]->setEnabled(true);
}
// Segundo texto de la primera imagen
if (texts[0]->hasFinished() && !texts[1]->hasFinished()) {
texts[0]->setEnabled(false);
texts[1]->setEnabled(true);
}
// Tercer texto de la primera imagen
if (texts[1]->hasFinished() && !texts[2]->hasFinished()) {
texts[1]->setEnabled(false);
texts[2]->setEnabled(true);
}
// Fin de la primera escena
if (texts[2]->hasFinished()) {
bitmaps[0]->setEnabled(false);
texts[2]->setEnabled(false);
scene++;
}
updateScene1();
break;
case 2:
// Segunda imagen - Máquina
if (!bitmaps[1]->hasFinished()) {
bitmaps[1]->setEnabled(true);
}
// Primer texto de la segunda imagen
if (bitmaps[1]->hasFinished() && !texts[3]->hasFinished()) {
texts[3]->setEnabled(true);
}
// Fin de la segunda escena
if (texts[3]->hasFinished()) {
bitmaps[1]->setEnabled(false);
texts[3]->setEnabled(false);
scene++;
}
updateScene2();
break;
case 3:
// Tercera imagen junto con primer texto - GRITO
if (!bitmaps[2]->hasFinished() && !texts[4]->hasFinished()) {
bitmaps[2]->setEnabled(true);
texts[4]->setEnabled(true);
}
// Fin de la tercera escena
if (bitmaps[2]->hasFinished() && texts[4]->hasFinished()) {
bitmaps[2]->setEnabled(false);
texts[4]->setEnabled(false);
scene++;
}
updateScene3();
break;
case 4:
// Cuarta imagen junto con primer texto - Reflexión
if (!bitmaps[3]->hasFinished() && !texts[5]->hasFinished()) {
bitmaps[3]->setEnabled(true);
texts[5]->setEnabled(true);
}
// Segundo texto de la cuarta imagen
if (texts[5]->hasFinished() && !texts[6]->hasFinished()) {
texts[5]->setEnabled(false);
texts[6]->setEnabled(true);
}
// Fin de la cuarta escena
if (bitmaps[3]->hasFinished() && texts[6]->hasFinished()) {
bitmaps[3]->setEnabled(false);
texts[6]->setEnabled(false);
scene++;
}
updateScene4();
break;
case 5:
// Quinta imagen - Patada
if (!bitmaps[4]->hasFinished()) {
bitmaps[4]->setEnabled(true);
}
// Primer texto de la quinta imagen
if (bitmaps[4]->hasFinished() && !texts[7]->hasFinished()) {
texts[7]->setEnabled(true);
}
// Fin de la quinta escena
if (bitmaps[4]->hasFinished() && texts[7]->hasFinished()) {
bitmaps[4]->setEnabled(false);
texts[7]->setEnabled(false);
scene++;
}
updateScene5();
break;
case 6:
// Sexta imagen junto con texto - Globos de café
if (!bitmaps[5]->hasFinished() && !texts[8]->hasFinished()) {
bitmaps[5]->setEnabled(true);
texts[8]->setEnabled(true);
}
// Acaba el último texto
if (bitmaps[5]->hasFinished() && texts[8]->hasFinished()) {
bitmaps[5]->setEnabled(false);
texts[8]->setEnabled(false);
Audio::get()->stopMusic();
section->name = SECTION_PROG_TITLE;
section->subsection = SUBSECTION_TITLE_1;
}
updateScene6();
break;
default:
break;
}
}
// Primera escena - UPV
void Intro::updateScene1() {
// Primera imagen - UPV
if (!bitmaps_[0]->hasFinished()) {
bitmaps_[0]->setEnabled(true);
}
// Primer texto de la primera imagen
if (bitmaps_[0]->hasFinished() && !texts_[0]->hasFinished()) {
texts_[0]->setEnabled(true);
}
// Segundo texto de la primera imagen
if (texts_[0]->hasFinished() && !texts_[1]->hasFinished()) {
texts_[0]->setEnabled(false);
texts_[1]->setEnabled(true);
}
// Tercer texto de la primera imagen
if (texts_[1]->hasFinished() && !texts_[2]->hasFinished()) {
texts_[1]->setEnabled(false);
texts_[2]->setEnabled(true);
}
// Fin de la primera escena
if (texts_[2]->hasFinished()) {
bitmaps_[0]->setEnabled(false);
texts_[2]->setEnabled(false);
scene_++;
}
}
// Segunda escena - Máquina
void Intro::updateScene2() {
// Segunda imagen - Máquina
if (!bitmaps_[1]->hasFinished()) {
bitmaps_[1]->setEnabled(true);
}
// Primer texto de la segunda imagen
if (bitmaps_[1]->hasFinished() && !texts_[3]->hasFinished()) {
texts_[3]->setEnabled(true);
}
// Fin de la segunda escena
if (texts_[3]->hasFinished()) {
bitmaps_[1]->setEnabled(false);
texts_[3]->setEnabled(false);
scene_++;
}
}
// Tercera escena - GRITO
void Intro::updateScene3() {
// Tercera imagen junto con primer texto - GRITO
if (!bitmaps_[2]->hasFinished() && !texts_[4]->hasFinished()) {
bitmaps_[2]->setEnabled(true);
texts_[4]->setEnabled(true);
}
// Fin de la tercera escena
if (bitmaps_[2]->hasFinished() && texts_[4]->hasFinished()) {
bitmaps_[2]->setEnabled(false);
texts_[4]->setEnabled(false);
scene_++;
}
}
// Cuarta escena - Reflexión
void Intro::updateScene4() {
// Cuarta imagen junto con primer texto - Reflexión
if (!bitmaps_[3]->hasFinished() && !texts_[5]->hasFinished()) {
bitmaps_[3]->setEnabled(true);
texts_[5]->setEnabled(true);
}
// Segundo texto de la cuarta imagen
if (texts_[5]->hasFinished() && !texts_[6]->hasFinished()) {
texts_[5]->setEnabled(false);
texts_[6]->setEnabled(true);
}
// Fin de la cuarta escena
if (bitmaps_[3]->hasFinished() && texts_[6]->hasFinished()) {
bitmaps_[3]->setEnabled(false);
texts_[6]->setEnabled(false);
scene_++;
}
}
// Quinta escena - Patada
void Intro::updateScene5() {
// Quinta imagen - Patada
if (!bitmaps_[4]->hasFinished()) {
bitmaps_[4]->setEnabled(true);
}
// Primer texto de la quinta imagen
if (bitmaps_[4]->hasFinished() && !texts_[7]->hasFinished()) {
texts_[7]->setEnabled(true);
}
// Fin de la quinta escena
if (bitmaps_[4]->hasFinished() && texts_[7]->hasFinished()) {
bitmaps_[4]->setEnabled(false);
texts_[7]->setEnabled(false);
scene_++;
}
}
// Sexta escena - Globos de café
void Intro::updateScene6() {
// Sexta imagen junto con texto - Globos de café
if (!bitmaps_[5]->hasFinished() && !texts_[8]->hasFinished()) {
bitmaps_[5]->setEnabled(true);
texts_[8]->setEnabled(true);
}
// Acaba el último texto
if (bitmaps_[5]->hasFinished() && texts_[8]->hasFinished()) {
bitmaps_[5]->setEnabled(false);
texts_[8]->setEnabled(false);
Audio::get()->stopMusic();
section_->name = SECTION_PROG_TITLE;
section_->subsection = SUBSECTION_TITLE_1;
}
}
// Actualiza las variables del objeto
void Intro::update() {
Audio::update();
checkInput();
if (SDL_GetTicks() - ticks > ticksSpeed) {
if (SDL_GetTicks() - ticks_ > ticks_speed_) {
// Actualiza el contador de ticks
ticks = SDL_GetTicks();
ticks_ = SDL_GetTicks();
// Actualiza los objetos
for (auto *bitmap : bitmaps) {
for (auto *bitmap : bitmaps_) {
bitmap->update();
}
for (auto *t : texts) {
for (auto *t : texts_) {
t->update();
}
@@ -351,11 +367,11 @@ void Intro::render() {
Screen::get()->clean(bgColor);
// Dibuja los objetos
for (auto *bitmap : bitmaps) {
for (auto *bitmap : bitmaps_) {
bitmap->render();
}
for (auto *t : texts) {
for (auto *t : texts_) {
t->render();
}
@@ -365,9 +381,9 @@ void Intro::render() {
// Bucle principal
void Intro::run() {
Audio::get()->playMusic(music, 0);
Audio::get()->playMusic(music_, 0);
while (section->name == SECTION_PROG_INTRO) {
while (section_->name == SECTION_PROG_INTRO) {
iterate();
}
}
+32 -39
View File
@@ -12,50 +12,43 @@ struct Section;
// Clase Intro
class Intro {
private:
// Objetos y punteros
SDL_Renderer *renderer; // El renderizador de la ventana
Texture *texture; // Textura con los graficos
SDL_Event *eventHandler; // Manejador de eventos
std::vector<SmartSprite *> bitmaps; // Vector con los sprites inteligentes para los dibujos de la intro
std::vector<Writer *> texts; // Textos de la intro
Text *text; // Textos de la intro
Section *section; // Estado del bucle principal para saber si continua o se sale
// Variables
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
Uint8 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
JA_Music_t *music; // Musica para la intro
int scene; // Indica que escena está activa
// Actualiza las variables del objeto
void update();
// Dibuja el objeto en pantalla
void render();
// Comprueba las entradas
void checkInput();
// Actualiza las escenas de la intro
void updateScenes();
public:
// Constructor
Intro(SDL_Renderer *renderer, Section *section);
// Destructor
~Intro();
Intro(SDL_Renderer *renderer, Section *section); // Constructor
~Intro(); // Destructor
Intro(const Intro &) = delete;
auto operator=(const Intro &) -> Intro & = delete;
// Bucle principal
void run();
void run(); // Bucle principal
void iterate(); // Ejecuta un frame
void handleEvent(const SDL_Event *event); // Procesa un evento
// Ejecuta un frame
void iterate();
private:
// Objetos y punteros
SDL_Renderer *renderer_; // El renderizador de la ventana
Texture *texture_; // Textura con los graficos
SDL_Event *event_handler_; // Manejador de eventos
std::vector<SmartSprite *> bitmaps_; // Vector con los sprites inteligentes para los dibujos de la intro
std::vector<Writer *> texts_; // Textos de la intro
Text *text_; // Textos de la intro
Section *section_; // Estado del bucle principal para saber si continua o se sale
// Procesa un evento
void handleEvent(const SDL_Event *event);
// Variables
Uint32 ticks_; // Contador de ticks para ajustar la velocidad del programa
Uint8 ticks_speed_; // Velocidad a la que se repiten los bucles del programa
JA_Music_t *music_; // Musica para la intro
int scene_; // Indica que escena está activa
void update(); // Actualiza las variables del objeto
void render(); // Dibuja el objeto en pantalla
void checkInput(); // Comprueba las entradas
void updateScenes(); // Actualiza las escenas de la intro
// Helpers de updateScenes, uno por cada escena
void updateScene1();
void updateScene2();
void updateScene3();
void updateScene4();
void updateScene5();
void updateScene6();
};
+25 -25
View File
@@ -23,20 +23,20 @@ constexpr int END_LOGO = 200;
// Constructor
Logo::Logo(SDL_Renderer *renderer, Section *section) {
// Copia la dirección de los objetos
this->renderer = renderer;
this->section = section;
this->renderer_ = renderer;
this->section_ = section;
// Reserva memoria para los punteros
eventHandler = new SDL_Event();
texture = Resource::get()->getTexture("logo.png");
sprite = new Sprite(14, 75, 226, 44, texture, renderer);
event_handler_ = new SDL_Event();
texture_ = Resource::get()->getTexture("logo.png");
sprite_ = new Sprite(14, 75, 226, 44, texture_, renderer);
// Inicializa variables
counter = 0;
counter_ = 0;
section->name = SECTION_PROG_LOGO;
section->subsection = 0;
ticks = 0;
ticksSpeed = 15;
ticks_ = 0;
ticks_speed_ = 15;
Audio::get()->stopMusic();
}
@@ -44,15 +44,15 @@ Logo::Logo(SDL_Renderer *renderer, Section *section) {
// Destructor
Logo::~Logo() {
// texture es propiedad de Resource — no liberar aquí.
delete sprite;
delete eventHandler;
delete sprite_;
delete event_handler_;
}
// Comprueba si ha terminado el logo
void Logo::checkLogoEnd() {
if (counter >= END_LOGO + 20) {
section->name = SECTION_PROG_INTRO;
section->subsection = 0;
if (counter_ >= END_LOGO + 20) {
section_->name = SECTION_PROG_INTRO;
section_->subsection = 0;
}
}
@@ -60,26 +60,26 @@ void Logo::checkLogoEnd() {
void Logo::checkInput() {
#ifndef __EMSCRIPTEN__
if (Input::get()->checkInput(input_exit, REPEAT_FALSE)) {
section->name = SECTION_PROG_QUIT;
section_->name = SECTION_PROG_QUIT;
return;
}
#endif
if (GlobalInputs::handle()) { return; }
if (Input::get()->checkInput(input_pause, REPEAT_FALSE) || Input::get()->checkInput(input_accept, REPEAT_FALSE) || Input::get()->checkInput(input_fire_left, REPEAT_FALSE) || Input::get()->checkInput(input_fire_center, REPEAT_FALSE) || Input::get()->checkInput(input_fire_right, REPEAT_FALSE)) {
section->name = SECTION_PROG_TITLE;
section->subsection = SUBSECTION_TITLE_1;
section_->name = SECTION_PROG_TITLE;
section_->subsection = SUBSECTION_TITLE_1;
}
}
// Dibuja el fade
void Logo::renderFade() {
// Dibuja el fade
if (counter >= INIT_FADE) {
const float step = (float)(counter - INIT_FADE) / (float)(END_LOGO - INIT_FADE);
if (counter_ >= INIT_FADE) {
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);
SDL_RenderFillRect(renderer, nullptr);
SDL_SetRenderDrawColor(renderer_, bgColor.r, bgColor.g, bgColor.b, alpha);
SDL_RenderFillRect(renderer_, nullptr);
}
}
@@ -88,12 +88,12 @@ void Logo::update() {
Audio::update();
checkInput();
if (SDL_GetTicks() - ticks > ticksSpeed) {
if (SDL_GetTicks() - ticks_ > ticks_speed_) {
// Actualiza el contador de ticks
ticks = SDL_GetTicks();
ticks_ = SDL_GetTicks();
// Actualiza el contador
counter++;
counter_++;
// Comprueba si ha terminado el logo
checkLogoEnd();
@@ -109,7 +109,7 @@ void Logo::render() {
Screen::get()->clean({238, 238, 238});
// Dibuja los objetos
sprite->render();
sprite_->render();
// Dibuja el fade
renderFade();
@@ -122,7 +122,7 @@ void Logo::render() {
void Logo::run() {
Audio::get()->stopMusic();
while (section->name == SECTION_PROG_LOGO) {
while (section_->name == SECTION_PROG_LOGO) {
iterate();
}
}
+22 -39
View File
@@ -7,50 +7,33 @@ struct Section;
// Clase Logo
class Logo {
private:
// Objetos y punteros
SDL_Renderer *renderer; // El renderizador de la ventana
Texture *texture; // Textura con los graficos
SDL_Event *eventHandler; // Manejador de eventos
Sprite *sprite; // Sprite con la textura del logo
Section *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
int counter; // Contador
// Actualiza las variables del objeto
void update();
// Dibuja el objeto en pantalla
void render();
// Comprueba si ha terminado el logo
void checkLogoEnd();
// Comprueba las entradas
void checkInput();
// Dibuja el fade
void renderFade();
public:
// Constructor
Logo(SDL_Renderer *renderer, Section *section);
// Destructor
~Logo();
Logo(SDL_Renderer *renderer, Section *section); // Constructor
~Logo(); // Destructor
Logo(const Logo &) = delete;
auto operator=(const Logo &) -> Logo & = delete;
// Bucle principal
void run();
void run(); // Bucle principal
void iterate(); // Ejecuta un frame
void handleEvent(const SDL_Event *event); // Procesa un evento
// Ejecuta un frame
void iterate();
private:
// Objetos y punteros
SDL_Renderer *renderer_; // El renderizador de la ventana
Texture *texture_; // Textura con los graficos
SDL_Event *event_handler_; // Manejador de eventos
Sprite *sprite_; // Sprite con la textura del logo
Section *section_; // Estado del bucle principal para saber si continua o se sale
// Procesa un evento
void handleEvent(const SDL_Event *event);
// Variables
Uint32 ticks_; // Contador de ticks para ajustar la velocidad del programa
Uint32 ticks_speed_; // Velocidad a la que se repiten los bucles del programa
int counter_; // Contador
void update(); // Actualiza las variables del objeto
void render(); // Dibuja el objeto en pantalla
void checkLogoEnd(); // Comprueba si ha terminado el logo
void checkInput(); // Comprueba las entradas
void renderFade(); // Dibuja el fade
};
+5 -5
View File
@@ -457,7 +457,7 @@ void Title::update() {
break;
case 11: // HOW TO PLAY
runInstructions(m_manual);
runInstructions(Instructions::Mode::MANUAL);
break;
case 12: // ACCEPT
@@ -495,7 +495,7 @@ void Title::update() {
// Sección Instrucciones
if (section->subsection == SUBSECTION_TITLE_INSTRUCTIONS) {
runInstructions(m_auto);
runInstructions(Instructions::Mode::AUTO);
}
}
@@ -845,7 +845,7 @@ void Title::iterate() {
if (wasQuit) {
section->name = SECTION_PROG_QUIT;
} else if (instructionsMode == m_auto) {
} else if (instructionsMode == Instructions::Mode::AUTO) {
section->name = SECTION_PROG_TITLE;
init();
demo = true;
@@ -877,7 +877,7 @@ void Title::iterate() {
section->name = SECTION_PROG_TITLE;
section->subsection = SUBSECTION_TITLE_3;
demoThenInstructions = false;
runInstructions(m_auto);
runInstructions(Instructions::Mode::AUTO);
} else {
section->name = SECTION_PROG_TITLE;
section->subsection = SUBSECTION_TITLE_1;
@@ -929,7 +929,7 @@ void Title::run() {
}
// Inicia la parte donde se muestran las instrucciones
void Title::runInstructions(InstructionsMode mode) {
void Title::runInstructions(Instructions::Mode mode) {
instructions = new Instructions(renderer, section);
instructions->start(mode);
instructionsActive = true;
+10 -10
View File
@@ -5,7 +5,7 @@
#include <vector> // for vector
#include "game/options.hpp" // for Options::Video, Options::Window (per snapshot cancel)
#include "game/scenes/instructions.h" // for InstructionsMode
#include "game/scenes/instructions.h" // for Instructions::Mode
#include "utils/utils.h" // for InputDevice, Section
class AnimatedSprite;
class Fade;
@@ -42,7 +42,7 @@ class Title {
Instructions *instructions{nullptr}; // Objeto para la sección de las instrucciones
Game *demoGame{nullptr}; // Objeto para lanzar la demo del juego
SDL_Event *eventHandler; // Manejador de eventos
Section *section; // Indicador para el bucle del titulo
Section *section; // Indicador para el bucle del titulo
Texture *dustTexture; // Textura con los graficos del polvo
Texture *coffeeTexture; // Textura con los graficos de la palabra coffee
@@ -74,17 +74,17 @@ class Title {
float sin[360]; // Vector con los valores del seno precalculados
bool menuVisible; // Indicador para saber si se muestra el menu del titulo o la frase intermitente
bool demo; // Indica si el modo demo estará activo
Section nextSection; // Indica cual es la siguiente sección a cargar cuando termine el contador del titulo
Section nextSection; // Indica cual es la siguiente sección a cargar cuando termine el contador del titulo
Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
Uint8 postFade; // Opción a realizar cuando termina el fundido
MenuData menu; // Variable con todos los objetos menus y sus variables
MenuData menu; // Variable con todos los objetos menus y sus variables
// Snapshot per a permetre CANCEL al menú d'opcions.
Options::Video prevVideo;
Options::Window prevWindow;
Options::Settings prevSettings;
std::vector<InputDevice> prevInputs;
std::vector<InputDevice> availableInputDevices; // Vector con todos los metodos de control disponibles
std::vector<int> deviceIndex; // Indice para el jugador [i] del vector de dispositivos de entrada disponibles
std::vector<int> deviceIndex; // Indice para el jugador [i] del vector de dispositivos de entrada disponibles
// Variables para la vibración del título (SUBSECTION_TITLE_2)
int vibrationStep; // Paso actual de la vibración
@@ -93,10 +93,10 @@ class Title {
bool vibrationInitialized; // Indica si se han capturado las posiciones base
// Variables para sub-estados delegados (instrucciones y demo)
bool instructionsActive; // Indica si las instrucciones están activas
bool demoGameActive; // Indica si el juego demo está activo
InstructionsMode instructionsMode{m_auto}; // Modo de las instrucciones activas
bool demoThenInstructions; // Indica si tras la demo hay que mostrar instrucciones
bool instructionsActive; // Indica si las instrucciones están activas
bool demoGameActive; // Indica si el juego demo está activo
Instructions::Mode instructionsMode{Instructions::Mode::AUTO}; // Modo de las instrucciones activas
bool demoThenInstructions; // Indica si tras la demo hay que mostrar instrucciones
// Inicializa los valores
void init();
@@ -123,7 +123,7 @@ class Title {
void applyOptions();
// Ejecuta la parte donde se muestran las instrucciones
void runInstructions(InstructionsMode mode);
void runInstructions(Instructions::Mode mode);
// Ejecuta el juego en modo demo
void runDemoGame();