forked from jaildesigner-jailgames/jaildoctors_dilemma
mogut options.section a SceneManager
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
#include "game/scene_manager.hpp" // Para SceneManager
|
||||
|
||||
#include "game/scenes/credits.hpp"
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
@@ -19,8 +21,8 @@
|
||||
Credits::Credits()
|
||||
: shining_sprite_(std::make_shared<SAnimatedSprite>(Resource::get()->getSurface("shine.gif"), Resource::get()->getAnimations("shine.ani"))) {
|
||||
// Inicializa variables
|
||||
Options::section.section = Options::Scene::CREDITS;
|
||||
Options::section.subsection = Options::SceneOptions::NONE;
|
||||
SceneManager::current = SceneManager::Scene::CREDITS;
|
||||
SceneManager::options = SceneManager::Options::NONE;
|
||||
shining_sprite_->setPos({194, 174, 8, 8});
|
||||
|
||||
// Cambia el color del borde
|
||||
@@ -165,7 +167,7 @@ void Credits::updateCounter() {
|
||||
|
||||
// Comprueba si ha terminado la sección
|
||||
if (counter_ > 1200) {
|
||||
Options::section.section = Options::Scene::DEMO;
|
||||
SceneManager::current = SceneManager::Scene::DEMO;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -218,7 +220,7 @@ void Credits::render() {
|
||||
|
||||
// Bucle para el logo del juego
|
||||
void Credits::run() {
|
||||
while (Options::section.section == Options::Scene::CREDITS) {
|
||||
while (SceneManager::current == SceneManager::Scene::CREDITS) {
|
||||
update();
|
||||
checkEvents();
|
||||
render();
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
#include "game/scene_manager.hpp" // Para SceneManager
|
||||
|
||||
#include "game/scenes/ending.hpp"
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
@@ -23,8 +25,8 @@ Ending::Ending()
|
||||
cover_counter_(0),
|
||||
ticks_(0),
|
||||
current_scene_(0) {
|
||||
Options::section.section = Options::Scene::ENDING;
|
||||
Options::section.subsection = Options::SceneOptions::NONE;
|
||||
SceneManager::current = SceneManager::Scene::ENDING;
|
||||
SceneManager::options = SceneManager::Options::NONE;
|
||||
|
||||
// Inicializa los textos
|
||||
iniTexts();
|
||||
@@ -359,7 +361,7 @@ void Ending::iniScenes() {
|
||||
void Ending::run() {
|
||||
JA_PlayMusic(Resource::get()->getMusic("ending1.ogg"));
|
||||
|
||||
while (Options::section.section == Options::Scene::ENDING) {
|
||||
while (SceneManager::current == SceneManager::Scene::ENDING) {
|
||||
update();
|
||||
checkEvents();
|
||||
render();
|
||||
@@ -423,7 +425,7 @@ void Ending::checkChangeScene() {
|
||||
cover_counter_ = 0;
|
||||
if (current_scene_ == 5) {
|
||||
// Termina el bucle
|
||||
Options::section.section = Options::Scene::ENDING2;
|
||||
SceneManager::current = SceneManager::Scene::ENDING2;
|
||||
|
||||
// Mantiene los valores anteriores
|
||||
current_scene_ = 4;
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
#include "game/scene_manager.hpp" // Para SceneManager
|
||||
|
||||
#include "game/scenes/ending2.hpp"
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
@@ -20,8 +22,8 @@
|
||||
// Constructor
|
||||
Ending2::Ending2()
|
||||
: state_(EndingState::PRE_CREDITS, SDL_GetTicks(), STATE_PRE_CREDITS_DURATION_) {
|
||||
Options::section.section = Options::Scene::ENDING2;
|
||||
Options::section.subsection = Options::SceneOptions::NONE;
|
||||
SceneManager::current = SceneManager::Scene::ENDING2;
|
||||
SceneManager::options = SceneManager::Options::NONE;
|
||||
|
||||
// Inicializa el vector de colores
|
||||
const std::vector<std::string> COLORS = {"white", "yellow", "cyan", "green", "magenta", "red", "blue", "black"};
|
||||
@@ -146,7 +148,7 @@ void Ending2::checkInput() {
|
||||
void Ending2::run() {
|
||||
JA_PlayMusic(Resource::get()->getMusic("ending2.ogg"));
|
||||
|
||||
while (Options::section.section == Options::Scene::ENDING2) {
|
||||
while (SceneManager::current == SceneManager::Scene::ENDING2) {
|
||||
update();
|
||||
checkEvents();
|
||||
render();
|
||||
@@ -179,8 +181,8 @@ void Ending2::updateState() {
|
||||
|
||||
case EndingState::FADING:
|
||||
if (state_.hasEnded(EndingState::FADING)) {
|
||||
Options::section.section = Options::Scene::LOGO;
|
||||
Options::section.subsection = Options::SceneOptions::LOGO_TO_INTRO;
|
||||
SceneManager::current = SceneManager::Scene::LOGO;
|
||||
SceneManager::options = SceneManager::Options::LOGO_TO_INTRO;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
#include "game/scene_manager.hpp" // Para SceneManager
|
||||
|
||||
#include "game/scenes/game.hpp"
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
@@ -58,8 +60,8 @@ Game::Game(GameMode mode)
|
||||
Cheevos::get()->enable(!Options::cheats.enabled()); // Deshabilita los logros si hay trucos activados
|
||||
Cheevos::get()->clearUnobtainableState();
|
||||
|
||||
Options::section.section = (mode_ == GameMode::GAME) ? Options::Scene::GAME : Options::Scene::DEMO;
|
||||
Options::section.subsection = Options::SceneOptions::NONE;
|
||||
SceneManager::current = (mode_ == GameMode::GAME) ? SceneManager::Scene::GAME : SceneManager::Scene::DEMO;
|
||||
SceneManager::options = SceneManager::Options::NONE;
|
||||
}
|
||||
|
||||
Game::~Game() {
|
||||
@@ -100,7 +102,7 @@ void Game::run() {
|
||||
JA_PauseMusic();
|
||||
}
|
||||
|
||||
while (Options::section.section == Options::Scene::GAME || Options::section.section == Options::Scene::DEMO) {
|
||||
while (SceneManager::current == SceneManager::Scene::GAME || SceneManager::current == SceneManager::Scene::DEMO) {
|
||||
update();
|
||||
checkEvents();
|
||||
render();
|
||||
@@ -335,7 +337,7 @@ void Game::checkIfPlayerIsAlive() {
|
||||
// Comprueba si ha terminado la partida
|
||||
void Game::checkGameOver() {
|
||||
if (board_->lives < 0 && black_screen_counter_ > 17) {
|
||||
Options::section.section = Options::Scene::GAME_OVER;
|
||||
SceneManager::current = SceneManager::Scene::GAME_OVER;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -427,7 +429,7 @@ bool Game::checkEndGame() {
|
||||
// Comprueba los logros de completar el juego
|
||||
checkEndGameCheevos();
|
||||
|
||||
Options::section.section = Options::Scene::ENDING;
|
||||
SceneManager::current = SceneManager::Scene::ENDING;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -610,8 +612,8 @@ void Game::DEMO_checkRoomChange() {
|
||||
demo_.counter = 0;
|
||||
demo_.room_index++;
|
||||
if (demo_.room_index == (int)demo_.rooms.size()) {
|
||||
Options::section.section = Options::Scene::LOGO;
|
||||
Options::section.subsection = Options::SceneOptions::LOGO_TO_TITLE;
|
||||
SceneManager::current = SceneManager::Scene::LOGO;
|
||||
SceneManager::options = SceneManager::Options::LOGO_TO_TITLE;
|
||||
} else {
|
||||
changeRoom(demo_.rooms[demo_.room_index]);
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
#include "game/scene_manager.hpp" // Para SceneManager
|
||||
|
||||
#include "game/scenes/game_over.hpp"
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
@@ -23,8 +25,8 @@ GameOver::GameOver()
|
||||
pre_counter_(0),
|
||||
counter_(0),
|
||||
ticks_(0) {
|
||||
Options::section.section = Options::Scene::GAME_OVER;
|
||||
Options::section.subsection = Options::SceneOptions::NONE;
|
||||
SceneManager::current = SceneManager::Scene::GAME_OVER;
|
||||
SceneManager::options = SceneManager::Options::NONE;
|
||||
|
||||
player_sprite_->setPosX(GAMECANVAS_CENTER_X + 10);
|
||||
player_sprite_->setPosY(30);
|
||||
@@ -112,7 +114,7 @@ void GameOver::checkInput() {
|
||||
|
||||
// Bucle principal
|
||||
void GameOver::run() {
|
||||
while (Options::section.section == Options::Scene::GAME_OVER) {
|
||||
while (SceneManager::current == SceneManager::Scene::GAME_OVER) {
|
||||
update();
|
||||
checkEvents();
|
||||
render();
|
||||
@@ -156,7 +158,7 @@ void GameOver::updateCounters() {
|
||||
|
||||
// Comprueba si ha terminado la sección
|
||||
else if (counter_ == COUNTER_SECTION_END_) {
|
||||
Options::section.section = Options::Scene::LOGO;
|
||||
Options::section.subsection = Options::SceneOptions::LOGO_TO_TITLE;
|
||||
SceneManager::current = SceneManager::Scene::LOGO;
|
||||
SceneManager::options = SceneManager::Options::LOGO_TO_TITLE;
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
#include "game/scene_manager.hpp" // Para SceneManager
|
||||
|
||||
#include "game/scenes/loading_screen.hpp"
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
@@ -25,8 +27,8 @@ LoadingScreen::LoadingScreen()
|
||||
screen_surface_->clear(static_cast<Uint8>(PaletteColor::WHITE));
|
||||
|
||||
// Inicializa variables
|
||||
Options::section.section = Options::Scene::LOADING_SCREEN;
|
||||
Options::section.subsection = Options::SceneOptions::NONE;
|
||||
SceneManager::current = SceneManager::Scene::LOADING_SCREEN;
|
||||
SceneManager::options = SceneManager::Options::NONE;
|
||||
|
||||
// Establece el orden de las lineas para imitar el direccionamiento de memoria del spectrum
|
||||
for (int i = 0; i < 192; ++i) {
|
||||
@@ -96,8 +98,8 @@ void LoadingScreen::updateLoad() {
|
||||
|
||||
// Comprueba si ha terminado la intro
|
||||
if (load_counter_ >= 768) {
|
||||
Options::section.section = Options::Scene::TITLE;
|
||||
Options::section.subsection = Options::SceneOptions::TITLE_WITH_LOADING_SCREEN;
|
||||
SceneManager::current = SceneManager::Scene::TITLE;
|
||||
SceneManager::options = SceneManager::Options::TITLE_WITH_LOADING_SCREEN;
|
||||
JA_StopMusic();
|
||||
}
|
||||
}
|
||||
@@ -189,7 +191,7 @@ void LoadingScreen::run() {
|
||||
Screen::get()->clearRenderer();
|
||||
Screen::get()->render();
|
||||
|
||||
while (Options::section.section == Options::Scene::LOADING_SCREEN) {
|
||||
while (SceneManager::current == SceneManager::Scene::LOADING_SCREEN) {
|
||||
update();
|
||||
checkEvents();
|
||||
render();
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
#include "game/scene_manager.hpp" // Para SceneManager
|
||||
|
||||
#include "game/scenes/logo.hpp"
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
@@ -30,7 +32,7 @@ Logo::Logo()
|
||||
}
|
||||
|
||||
// Inicializa variables
|
||||
Options::section.section = Options::Scene::LOGO;
|
||||
SceneManager::current = SceneManager::Scene::LOGO;
|
||||
|
||||
// Inicializa el vector de colores
|
||||
const std::vector<Uint8> COLORS = {
|
||||
@@ -206,7 +208,7 @@ void Logo::render() {
|
||||
|
||||
// Bucle para el logo del juego
|
||||
void Logo::run() {
|
||||
while (Options::section.section == Options::Scene::LOGO) {
|
||||
while (SceneManager::current == SceneManager::Scene::LOGO) {
|
||||
update();
|
||||
checkEvents();
|
||||
render();
|
||||
@@ -215,11 +217,11 @@ void Logo::run() {
|
||||
|
||||
// Termina la sección
|
||||
void Logo::endSection() {
|
||||
if (Options::section.subsection == Options::SceneOptions::LOGO_TO_TITLE) {
|
||||
Options::section.section = Options::Scene::TITLE;
|
||||
if (SceneManager::options == SceneManager::Options::LOGO_TO_TITLE) {
|
||||
SceneManager::current = SceneManager::Scene::TITLE;
|
||||
}
|
||||
|
||||
else if (Options::section.subsection == Options::SceneOptions::LOGO_TO_INTRO) {
|
||||
Options::section.section = Options::Scene::LOADING_SCREEN;
|
||||
else if (SceneManager::options == SceneManager::Options::LOGO_TO_INTRO) {
|
||||
SceneManager::current = SceneManager::Scene::LOADING_SCREEN;
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
#include "game/scene_manager.hpp" // Para SceneManager
|
||||
|
||||
#include "game/scenes/title.hpp"
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
@@ -25,9 +27,9 @@ Title::Title()
|
||||
loading_screen_sprite_(std::make_shared<SSprite>(loading_screen_surface_, 0, 0, loading_screen_surface_->getWidth(), loading_screen_surface_->getHeight())),
|
||||
bg_surface_(std::make_shared<Surface>(Options::game.width, Options::game.height)) {
|
||||
// Inicializa variables
|
||||
state_ = Options::section.subsection == Options::SceneOptions::TITLE_WITH_LOADING_SCREEN ? TitleState::SHOW_LOADING_SCREEN : TitleState::SHOW_MENU;
|
||||
Options::section.section = Options::Scene::TITLE;
|
||||
Options::section.subsection = Options::SceneOptions::NONE;
|
||||
state_ = SceneManager::options == SceneManager::Options::TITLE_WITH_LOADING_SCREEN ? TitleState::SHOW_LOADING_SCREEN : TitleState::SHOW_MENU;
|
||||
SceneManager::current = SceneManager::Scene::TITLE;
|
||||
SceneManager::options = SceneManager::Options::NONE;
|
||||
initMarquee();
|
||||
|
||||
// Crea y rellena la textura para mostrar los logros
|
||||
@@ -68,8 +70,8 @@ void Title::checkEvents() {
|
||||
if (!show_cheevos_) {
|
||||
switch (event.key.key) {
|
||||
case SDLK_1:
|
||||
Options::section.section = Options::Scene::GAME;
|
||||
Options::section.subsection = Options::SceneOptions::NONE;
|
||||
SceneManager::current = SceneManager::Scene::GAME;
|
||||
SceneManager::options = SceneManager::Options::NONE;
|
||||
break;
|
||||
|
||||
case SDLK_2:
|
||||
@@ -180,8 +182,8 @@ void Title::update() {
|
||||
// Si el contador alcanza cierto valor, termina la seccion
|
||||
if (counter_ == 2200) {
|
||||
if (!show_cheevos_) {
|
||||
Options::section.section = Options::Scene::CREDITS;
|
||||
Options::section.subsection = Options::SceneOptions::NONE;
|
||||
SceneManager::current = SceneManager::Scene::CREDITS;
|
||||
SceneManager::options = SceneManager::Options::NONE;
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -228,7 +230,7 @@ void Title::render() {
|
||||
|
||||
// Bucle para el logo del juego
|
||||
void Title::run() {
|
||||
while (Options::section.section == Options::Scene::TITLE) {
|
||||
while (SceneManager::current == SceneManager::Scene::TITLE) {
|
||||
update();
|
||||
checkEvents();
|
||||
render();
|
||||
|
||||
Reference in New Issue
Block a user