Cambiada la variable section por un puntero

This commit is contained in:
2022-12-16 09:32:33 +01:00
parent 2abde36a5e
commit 4d8bb46a52
22 changed files with 191 additions and 216 deletions

View File

@@ -2,7 +2,7 @@
#include <iostream>
// Constructor
Game::Game(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options, Input *input, Debug *debug)
Game::Game(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options, Input *input, section_t *section, Debug *debug)
{
// Inicia algunas variables
board.iniClock = SDL_GetTicks();
@@ -19,6 +19,7 @@ Game::Game(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *as
this->input = input;
this->debug = debug;
this->options = options;
this->section = section;
#ifdef DEBUG
currentRoom = "01.room";
@@ -81,8 +82,8 @@ Game::Game(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *as
initStats();
stats->addVisit(room->getName());
section.name = SECTION_PROG_GAME;
section.subsection = 0;
section->name = SECTION_PROG_GAME;
section->subsection = 0;
}
Game::~Game()
@@ -112,7 +113,7 @@ void Game::checkEventHandler()
// Evento de salida de la aplicación
if (eventHandler->type == SDL_QUIT)
{
section.name = SECTION_PROG_QUIT;
section->name = SECTION_PROG_QUIT;
screen->setBorderColor(stringToColor(options->palette, "black"));
break;
}
@@ -127,7 +128,7 @@ void Game::checkEventHandler()
switch (eventHandler->key.keysym.scancode)
{
case SDL_SCANCODE_ESCAPE:
section.name = SECTION_PROG_TITLE;
section->name = SECTION_PROG_TITLE;
break;
#ifdef DEBUG
case SDL_SCANCODE_G:
@@ -213,7 +214,7 @@ void Game::checkEventHandler()
}
// Bucle para el juego
section_t Game::run()
void Game::run()
{
JA_PlayMusic(music);
if (!board.music)
@@ -221,15 +222,13 @@ section_t Game::run()
JA_PauseMusic();
}
while (section.name == SECTION_PROG_GAME)
while (section->name == SECTION_PROG_GAME)
{
update();
render();
}
JA_StopMusic();
return section;
}
// Actualiza el juego, las variables, comprueba la entrada, etc.
@@ -432,7 +431,7 @@ void Game::checkGameOver()
{
if (board.lives < 0 && blackScreenCounter > 17)
{
section.name = SECTION_PROG_GAME_OVER;
section->name = SECTION_PROG_GAME_OVER;
}
}
@@ -569,7 +568,7 @@ bool Game::checkEndGame()
if (haveTheItems && isOnTheRoom && isOnTheDoor)
{
section.name = SECTION_PROG_ENDING;
section->name = SECTION_PROG_ENDING;
return true;
}