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

@@ -5,13 +5,13 @@
#include <algorithm> // for min
#include <string> // for basic_string
#include "core/audio/jail_audio.hpp" // for JA_StopMusic
#include "core/audio/jail_audio.hpp" // for JA_StopMusic
#include "core/input/global_inputs.hpp" // for GlobalInputs::handle
#include "core/input/input.h" // for Input, REPEAT_FALSE, inputs_e
#include "core/rendering/screen.h" // for Screen
#include "core/rendering/sprite.h" // for Sprite
#include "core/rendering/texture.h" // for Texture
#include "core/resources/asset.h" // for Asset
#include "core/input/input.h" // for Input, REPEAT_FALSE, inputs_e
#include "core/rendering/screen.h" // for Screen
#include "core/rendering/sprite.h" // for Sprite
#include "core/rendering/texture.h" // for Texture
#include "core/resources/asset.h" // for Asset
#include "core/resources/resource.h"
#include "game/defaults.hpp" // for bgColor, SECTION_PROG_LOGO, SECTION_PROG...
#include "utils/utils.h" // for section_t, color_t
@@ -21,12 +21,9 @@ constexpr int INIT_FADE = 100;
constexpr int END_LOGO = 200;
// Constructor
Logo::Logo(SDL_Renderer *renderer, Screen *screen, Asset *asset, Input *input, section_t *section) {
Logo::Logo(SDL_Renderer *renderer, section_t *section) {
// Copia la dirección de los objetos
this->renderer = renderer;
this->screen = screen;
this->asset = asset;
this->input = input;
this->section = section;
// Reserva memoria para los punteros
@@ -76,14 +73,14 @@ void Logo::checkEvents() {
// Comprueba las entradas
void Logo::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)) {
section->name = SECTION_PROG_TITLE;
section->subsection = SUBSECTION_TITLE_1;
}
@@ -120,10 +117,10 @@ void Logo::update() {
// Dibuja el objeto en pantalla
void Logo::render() {
// Prepara para empezar a dibujar en la textura de juego
screen->start();
Screen::get()->start();
// Limpia la pantalla
screen->clean({238, 238, 238});
Screen::get()->clean({238, 238, 238});
// Dibuja los objetos
sprite->render();
@@ -132,7 +129,7 @@ void Logo::render() {
renderFade();
// Vuelca el contenido del renderizador en pantalla
screen->blit();
Screen::get()->blit();
}
// Bucle para el logo del juego