From d32170f7cf4bae7c98444cd4f840e985b54d0560 Mon Sep 17 00:00:00 2001 From: Sergio Valor Martinez Date: Tue, 8 Nov 2022 18:22:06 +0100 Subject: [PATCH] =?UTF-8?q?A=C3=B1adidos=20defines=20para=20RELEASE=20y=20?= =?UTF-8?q?MACOS=5FBUNDLE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/const.h | 3 ++ source/director.cpp | 11 ++++--- source/game.cpp | 73 +++++++++++++++++++++++++-------------------- source/game.h | 3 ++ 4 files changed, 53 insertions(+), 37 deletions(-) diff --git a/source/const.h b/source/const.h index 7de58b1..8500904 100644 --- a/source/const.h +++ b/source/const.h @@ -7,6 +7,9 @@ #ifndef CONST_H #define CONST_H +//#define MACOS_BUNDLE +//#define RELEASE + // Textos #define WINDOW_CAPTION "JailDoctor's Dilemma" #define TEXT_COPYRIGHT "@2022 JailDesigner" diff --git a/source/director.cpp b/source/director.cpp index ad4b44c..9c1b208 100644 --- a/source/director.cpp +++ b/source/director.cpp @@ -9,7 +9,9 @@ Director::Director(int argc, char *argv[]) section.name = SECTION_PROG_LOGO; section.subsection = SUBSECTION_LOGO_TO_INTRO; - section.name = SECTION_PROG_LOGO; +#ifndef RELEASE + section.name = SECTION_PROG_GAME; +#endif // Crea e inicializa las opciones del programa iniOptions(); @@ -966,11 +968,12 @@ bool Director::initSDL() // Crea el indice de ficheros bool Director::setFileList() { - std::string prefix = ""; -#define _MACOS_BUNDLE #ifdef MACOS_BUNDLE - prefix = "/../Resources"; + const std::string prefix = "/../Resources"; +#else + const std::string prefix = ""; #endif + // Texto asset->add(prefix + "/data/font/smb2.png", t_font); asset->add(prefix + "/data/font/smb2.txt", t_font); diff --git a/source/game.cpp b/source/game.cpp index 396c8f6..ad09799 100644 --- a/source/game.cpp +++ b/source/game.cpp @@ -18,12 +18,12 @@ Game::Game(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *as this->debug = debug; this->options = options; - // **** +#ifndef RELEASE currentRoom = "03.room"; const int x = 29; const int y = 13; spawnPoint = {x * 8, y * 8, 0, 0, 0, s_standing, SDL_FLIP_HORIZONTAL}; - // **** +#endif // Crea los objetos scoreboard = new ScoreBoard(renderer, resource, asset, options, &board); @@ -92,7 +92,7 @@ void Game::checkEventHandler() case SDL_SCANCODE_ESCAPE: section.name = SECTION_PROG_TITLE; break; - +#ifndef RELEASE case SDL_SCANCODE_G: debug->switchEnabled(); options->cheat.invincible = debug->getEnabled(); @@ -104,26 +104,30 @@ void Game::checkEventHandler() resource->reLoad(); break; + case SDL_SCANCODE_W: + goToRoom(BORDER_TOP); + break; + + case SDL_SCANCODE_A: + goToRoom(BORDER_LEFT); + break; + + case SDL_SCANCODE_S: + goToRoom(BORDER_BOTTOM); + break; + + case SDL_SCANCODE_D: + goToRoom(BORDER_RIGHT); + break; +#endif + case SDL_SCANCODE_M: board.music = !board.music; board.music ? JA_ResumeMusic() : JA_PauseMusic(); break; case SDL_SCANCODE_P: - if (paused) - { - player->resume(); - room->resume(); - scoreboard->resume(); - paused = false; - } - else - { - player->pause(); - room->pause(); - scoreboard->pause(); - paused = true; - } + switchPause(); break; case SDL_SCANCODE_B: @@ -160,22 +164,6 @@ void Game::checkEventHandler() switchPalette(); break; - case SDL_SCANCODE_W: - goToRoom(BORDER_TOP); - break; - - case SDL_SCANCODE_A: - goToRoom(BORDER_LEFT); - break; - - case SDL_SCANCODE_S: - goToRoom(BORDER_BOTTOM); - break; - - case SDL_SCANCODE_D: - goToRoom(BORDER_RIGHT); - break; - default: break; } @@ -559,4 +547,23 @@ void Game::goToRoom(int border) { currentRoom = roomName; } +} + +// Pone el juego en pausa +void Game::switchPause() +{ + if (paused) + { + player->resume(); + room->resume(); + scoreboard->resume(); + paused = false; + } + else + { + player->pause(); + room->pause(); + scoreboard->pause(); + paused = true; + } } \ No newline at end of file diff --git a/source/game.h b/source/game.h index 427102e..98a8353 100644 --- a/source/game.h +++ b/source/game.h @@ -120,6 +120,9 @@ private: // Va a la habitación designada void goToRoom(int border); + // Pone el juego en pausa + void switchPause(); + public: // Constructor Game(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options, Input *input, Debug *debug);