Convertit "param" a variable global en lloc de anar marejant amb punterets i passant 8.000.000 de paràmetres
This commit is contained in:
@@ -95,7 +95,6 @@ Director::~Director()
|
||||
delete input;
|
||||
delete screen;
|
||||
delete options;
|
||||
delete param;
|
||||
delete section;
|
||||
|
||||
deleteSounds();
|
||||
@@ -247,7 +246,7 @@ bool Director::initSDL()
|
||||
SDL_DisplayMode DM;
|
||||
SDL_GetCurrentDisplayMode(0, &DM);
|
||||
std::cout << "\nCurrent display mode: " + std::to_string(DM.w) + "x" + std::to_string(DM.h) + " @ " + std::to_string(DM.refresh_rate) + "Hz" << std::endl;
|
||||
std::cout << "Window resolution : " + std::to_string(param->game.width) + "x" + std::to_string(param->game.height) + " x" + std::to_string(options->video.window.size) << std::endl;
|
||||
std::cout << "Window resolution : " + std::to_string(param.game.width) + "x" + std::to_string(param.game.height) + " x" + std::to_string(options->video.window.size) << std::endl;
|
||||
}
|
||||
|
||||
// Establece el filtro de la textura
|
||||
@@ -268,7 +267,7 @@ bool Director::initSDL()
|
||||
}
|
||||
#endif
|
||||
// Crea la ventana
|
||||
window = SDL_CreateWindow(WINDOW_CAPTION, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, param->game.width * options->video.window.size, param->game.height * options->video.window.size, SDL_WINDOW_HIDDEN);
|
||||
window = SDL_CreateWindow(WINDOW_CAPTION, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, param.game.width * options->video.window.size, param.game.height * options->video.window.size, SDL_WINDOW_HIDDEN);
|
||||
if (window == nullptr)
|
||||
{
|
||||
if (options->console)
|
||||
@@ -305,7 +304,7 @@ bool Director::initSDL()
|
||||
SDL_SetRenderDrawColor(renderer, 0x00, 0x00, 0x00, 0xFF);
|
||||
|
||||
// Establece el tamaño del buffer de renderizado
|
||||
SDL_RenderSetLogicalSize(renderer, param->game.width, param->game.height);
|
||||
SDL_RenderSetLogicalSize(renderer, param.game.width, param.game.height);
|
||||
|
||||
// Establece el modo de mezcla
|
||||
SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_BLEND);
|
||||
@@ -467,15 +466,13 @@ bool Director::setFileList()
|
||||
// Carga los parametros para configurar el juego
|
||||
void Director::loadParams(std::string filepath)
|
||||
{
|
||||
param = new param_t;
|
||||
|
||||
loadParamsFromFile(param, filepath);
|
||||
loadParamsFromFile(filepath);
|
||||
|
||||
// Modifica las opciones desde el fichero de parametros
|
||||
options->video.window.width = options->video.window.size * param->game.width;
|
||||
options->video.window.height = options->video.window.size * param->game.height;
|
||||
options->video.gameWidth = param->game.width;
|
||||
options->video.gameHeight = param->game.height;
|
||||
options->video.window.width = options->video.window.size * param.game.width;
|
||||
options->video.window.height = options->video.window.size * param.game.height;
|
||||
options->video.gameWidth = param.game.width;
|
||||
options->video.gameHeight = param.game.height;
|
||||
}
|
||||
|
||||
// Inicializa las opciones del programa
|
||||
@@ -886,7 +883,7 @@ void Director::deleteMusics()
|
||||
// Ejecuta la sección con el logo
|
||||
void Director::runLogo()
|
||||
{
|
||||
logo = new Logo(screen, asset, input, options, param, section);
|
||||
logo = new Logo(screen, asset, input, options, section);
|
||||
logo->run();
|
||||
delete logo;
|
||||
}
|
||||
@@ -894,7 +891,7 @@ void Director::runLogo()
|
||||
// Ejecuta la sección con la secuencia de introducción
|
||||
void Director::runIntro()
|
||||
{
|
||||
intro = new Intro(screen, asset, input, options, param, section, getMusic(musics, "intro.ogg"));
|
||||
intro = new Intro(screen, asset, input, options, section, getMusic(musics, "intro.ogg"));
|
||||
intro->run();
|
||||
delete intro;
|
||||
}
|
||||
@@ -902,7 +899,7 @@ void Director::runIntro()
|
||||
// Ejecuta la sección con el titulo del juego
|
||||
void Director::runTitle()
|
||||
{
|
||||
title = new Title(screen, asset, input, options, param, section, getMusic(musics, "title.ogg"));
|
||||
title = new Title(screen, asset, input, options, section, getMusic(musics, "title.ogg"));
|
||||
title->run();
|
||||
delete title;
|
||||
}
|
||||
@@ -912,7 +909,7 @@ void Director::runGame()
|
||||
{
|
||||
const int playerID = section->options;
|
||||
const int currentStage = 0;
|
||||
game = new Game(playerID, currentStage, GAME_MODE_DEMO_OFF, screen, asset, input, options, param, section, getMusic(musics, "playing.ogg"));
|
||||
game = new Game(playerID, currentStage, GAME_MODE_DEMO_OFF, screen, asset, input, options, section, getMusic(musics, "playing.ogg"));
|
||||
game->run();
|
||||
delete game;
|
||||
}
|
||||
@@ -920,7 +917,7 @@ void Director::runGame()
|
||||
// Ejecuta la sección donde se muestran las instrucciones
|
||||
void Director::runInstructions()
|
||||
{
|
||||
instructions = new Instructions(screen, asset, input, options, param, section, getMusic(musics, "title.ogg"));
|
||||
instructions = new Instructions(screen, asset, input, options, section, getMusic(musics, "title.ogg"));
|
||||
instructions->run();
|
||||
delete instructions;
|
||||
}
|
||||
@@ -928,7 +925,7 @@ void Director::runInstructions()
|
||||
// Ejecuta la sección donde se muestra la tabla de puntuaciones
|
||||
void Director::runHiScoreTable()
|
||||
{
|
||||
hiScoreTable = new HiScoreTable(screen, asset, input, options, param, section, getMusic(musics, "title.ogg"));
|
||||
hiScoreTable = new HiScoreTable(screen, asset, input, options, section, getMusic(musics, "title.ogg"));
|
||||
hiScoreTable->run();
|
||||
delete hiScoreTable;
|
||||
}
|
||||
@@ -938,7 +935,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, options, param, section, nullptr);
|
||||
demoGame = new Game(playerID, currentStage, GAME_MODE_DEMO_ON, screen, asset, input, options, section, nullptr);
|
||||
demoGame->run();
|
||||
delete demoGame;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user