Eliminat el punter a "section"

This commit is contained in:
2024-09-28 09:28:22 +02:00
parent 0a8d0479a0
commit 8d263931b2
19 changed files with 191 additions and 172 deletions

View File

@@ -2,6 +2,7 @@
#include "utils.h"
#include "const.h"
#include "options.h"
#include "section.h"
#include <iostream>
#include <fstream>
#include <string>
@@ -16,15 +17,13 @@
// Constructor
Director::Director(int argc, char *argv[])
{
// Inicializa variables
section = new section_t();
#ifdef RECORDING
section->name = SECTION_PROG_GAME;
section->options = SECTION_OPTIONS_GAME_PLAY_1P;
section::name = section::NAME_GAME;
section::options = section::OPTIONS_GAME_PLAY_1P;
#elif DEBUG
section->name = SECTION_PROG_LOGO;
section::name = section::NAME_LOGO;
#else
section->name = SECTION_PROG_LOGO;
section::name = section::NAME_LOGO;
#endif
// Comprueba los parametros del programa
@@ -90,7 +89,6 @@ Director::~Director()
delete asset;
delete input;
delete screen;
delete section;
deleteSounds();
deleteMusics();
@@ -602,7 +600,7 @@ void Director::deleteMusics()
// Ejecuta la sección con el logo
void Director::runLogo()
{
logo = new Logo(screen, asset, input, section);
logo = new Logo(screen, asset, input);
logo->run();
delete logo;
}
@@ -610,7 +608,7 @@ void Director::runLogo()
// Ejecuta la sección con la secuencia de introducción
void Director::runIntro()
{
intro = new Intro(screen, asset, input, section, getMusic(musics, "intro.ogg"));
intro = new Intro(screen, asset, input, getMusic(musics, "intro.ogg"));
intro->run();
delete intro;
}
@@ -618,7 +616,7 @@ void Director::runIntro()
// Ejecuta la sección con el titulo del juego
void Director::runTitle()
{
title = new Title(screen, asset, input, section, getMusic(musics, "title.ogg"));
title = new Title(screen, asset, input, getMusic(musics, "title.ogg"));
title->run();
delete title;
}
@@ -626,9 +624,9 @@ void Director::runTitle()
// Ejecuta la sección donde se juega al juego
void Director::runGame()
{
const int playerID = section->options;
const int playerID = section::options;
const int currentStage = 0;
game = new Game(playerID, currentStage, GAME_MODE_DEMO_OFF, screen, asset, input, section, getMusic(musics, "playing.ogg"));
game = new Game(playerID, currentStage, GAME_MODE_DEMO_OFF, screen, asset, input, getMusic(musics, "playing.ogg"));
game->run();
delete game;
}
@@ -636,7 +634,7 @@ void Director::runGame()
// Ejecuta la sección donde se muestran las instrucciones
void Director::runInstructions()
{
instructions = new Instructions(screen, asset, input, section, getMusic(musics, "title.ogg"));
instructions = new Instructions(screen, asset, input, getMusic(musics, "title.ogg"));
instructions->run();
delete instructions;
}
@@ -644,7 +642,7 @@ void Director::runInstructions()
// Ejecuta la sección donde se muestra la tabla de puntuaciones
void Director::runHiScoreTable()
{
hiScoreTable = new HiScoreTable(screen, asset, input, section, getMusic(musics, "title.ogg"));
hiScoreTable = new HiScoreTable(screen, asset, input, getMusic(musics, "title.ogg"));
hiScoreTable->run();
delete hiScoreTable;
}
@@ -654,7 +652,7 @@ void Director::runDemoGame()
{
const int playerID = (rand() % 2) + 1;
const int currentStage = 0;
demoGame = new Game(playerID, currentStage, GAME_MODE_DEMO_ON, screen, asset, input, section, nullptr);
demoGame = new Game(playerID, currentStage, GAME_MODE_DEMO_ON, screen, asset, input, nullptr);
demoGame->run();
delete demoGame;
}
@@ -662,45 +660,48 @@ void Director::runDemoGame()
int Director::run()
{
// Bucle principal
while (section->name != SECTION_PROG_QUIT)
while (section::name != section::NAME_QUIT)
{
switch (section->name)
switch (section::name)
{
case SECTION_PROG_INIT:
section->name = SECTION_PROG_LOGO;
case section::NAME_INIT:
section::name = section::NAME_LOGO;
break;
case SECTION_PROG_LOGO:
case section::NAME_LOGO:
runLogo();
break;
case SECTION_PROG_INTRO:
case section::NAME_INTRO:
runIntro();
break;
case SECTION_PROG_TITLE:
case section::NAME_TITLE:
runTitle();
break;
case SECTION_PROG_GAME:
case section::NAME_GAME:
runGame();
break;
case SECTION_PROG_HI_SCORE_TABLE:
case section::NAME_HI_SCORE_TABLE:
runHiScoreTable();
break;
case SECTION_PROG_GAME_DEMO:
case section::NAME_GAME_DEMO:
runDemoGame();
break;
case SECTION_PROG_INSTRUCTIONS:
case section::NAME_INSTRUCTIONS:
runInstructions();
break;
default:
break;
}
}
const int returnCode = section->options == SECTION_OPTIONS_QUIT_NORMAL ? 0 : 1;
const int returnCode = section::options == section::OPTIONS_QUIT_NORMAL ? 0 : 1;
return returnCode;
}