singletons

This commit is contained in:
2026-04-17 21:27:30 +02:00
parent 5889df2a47
commit 513eacf356
27 changed files with 536 additions and 505 deletions

View File

@@ -4,28 +4,23 @@
#include <string> // for basic_string
#include "core/audio/jail_audio.hpp" // for JA_StopMusic, JA_DeleteMusic, JA_LoadMusic
#include "core/audio/jail_audio.hpp" // for JA_StopMusic, JA_DeleteMusic, JA_LoadMusic
#include "core/input/global_inputs.hpp" // for GlobalInputs::handle
#include "core/input/input.h" // for Input, REPEAT_FALSE, inputs_e
#include "core/input/input.h" // for Input, REPEAT_FALSE, inputs_e
#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/asset.h" // for Asset
#include "core/resources/resource.h"
#include "game/defaults.hpp" // for GAMECANVAS_CENTER_X, GAMECANVAS_FIRST_QU...
#include "utils/utils.h" // for section_t, color_t
// Constructor
Intro::Intro(SDL_Renderer *renderer, Screen *screen, Asset *asset, Input *input, Lang *lang, section_t *section) {
Intro::Intro(SDL_Renderer *renderer, section_t *section) {
// Copia los punteros
this->renderer = renderer;
this->screen = screen;
this->lang = lang;
this->asset = asset;
this->input = input;
this->section = section;
// Reserva memoria para los objetos
@@ -115,39 +110,39 @@ Intro::Intro(SDL_Renderer *renderer, Screen *screen, Asset *asset, Input *input,
}
// Un dia qualsevol de l'any 2000
texts[0]->setCaption(lang->getText(27));
texts[0]->setCaption(Lang::get()->getText(27));
texts[0]->setSpeed(8);
// Tot esta tranquil a la UPV
texts[1]->setCaption(lang->getText(28));
texts[1]->setCaption(Lang::get()->getText(28));
texts[1]->setSpeed(8);
// Fins que un desaprensiu...
texts[2]->setCaption(lang->getText(29));
texts[2]->setCaption(Lang::get()->getText(29));
texts[2]->setSpeed(12);
// HEY! ME ANE A FERME UN CORTAET...
texts[3]->setCaption(lang->getText(30));
texts[3]->setCaption(Lang::get()->getText(30));
texts[3]->setSpeed(8);
// UAAAAAAAAAAAAA!!!
texts[4]->setCaption(lang->getText(31));
texts[4]->setCaption(Lang::get()->getText(31));
texts[4]->setSpeed(1);
// Espera un moment...
texts[5]->setCaption(lang->getText(32));
texts[5]->setCaption(Lang::get()->getText(32));
texts[5]->setSpeed(16);
// Si resulta que no tinc solt!
texts[6]->setCaption(lang->getText(33));
texts[6]->setCaption(Lang::get()->getText(33));
texts[6]->setSpeed(2);
// MERDA DE MAQUINA!
texts[7]->setCaption(lang->getText(34));
texts[7]->setCaption(Lang::get()->getText(34));
texts[7]->setSpeed(3);
// Blop... blop... blop...
texts[8]->setCaption(lang->getText(35));
texts[8]->setCaption(Lang::get()->getText(35));
texts[8]->setSpeed(16);
for (auto text : texts) {
@@ -193,14 +188,14 @@ void Intro::checkEvents() {
// Comprueba las entradas
void Intro::checkInput() {
#ifndef __EMSCRIPTEN__
if (input->checkInput(input_exit, REPEAT_FALSE)) {
if (Input::get()->checkInput(input_exit, REPEAT_FALSE)) {
section->name = SECTION_PROG_QUIT;
return;
}
#endif
if (GlobalInputs::handle(screen, input)) { return; }
if (GlobalInputs::handle()) { return; }
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 (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)) {
JA_StopMusic();
section->name = SECTION_PROG_TITLE;
section->subsection = SUBSECTION_TITLE_1;
@@ -369,10 +364,10 @@ void Intro::update() {
// Dibuja el objeto en pantalla
void Intro::render() {
// Prepara para empezar a dibujar en la textura de juego
screen->start();
Screen::get()->start();
// Limpia la pantalla
screen->clean(bgColor);
Screen::get()->clean(bgColor);
// Dibuja los objetos
for (auto bitmap : bitmaps) {
@@ -384,7 +379,7 @@ void Intro::render() {
}
// Vuelca el contenido del renderizador en pantalla
screen->blit();
Screen::get()->blit();
}
// Bucle principal