forked from jaildesigner-jailgames/jaildoctors_dilemma
JA VA! Nomes s'havia de fer les coses be i no ser un ansias
This commit is contained in:
@@ -11,10 +11,11 @@
|
||||
#include "screen.h" // Para Screen
|
||||
#include "text.h" // Para Text, TXT_CENTER, TXT_COLOR
|
||||
#include "utils.h" // Para color_t, stringToColor, options_t, secti...
|
||||
#include "options.h"
|
||||
class Debug;
|
||||
|
||||
// Constructor
|
||||
Demo::Demo(Resource *resource, options_t *options, section_t *section, Debug *debug)
|
||||
Demo::Demo(Resource *resource, Debug *debug)
|
||||
{
|
||||
// Inicia algunas variables
|
||||
board.iniClock = SDL_GetTicks();
|
||||
@@ -36,14 +37,12 @@ Demo::Demo(Resource *resource, options_t *options, section_t *section, Debug *de
|
||||
this->renderer = Screen::get()->getRenderer();
|
||||
this->asset = Asset::get();
|
||||
this->input = Input::get();
|
||||
this->options = options;
|
||||
this->section = section;
|
||||
this->debug = debug;
|
||||
|
||||
// Crea los objetos
|
||||
itemTracker = new ItemTracker();
|
||||
scoreboard = new ScoreBoard(renderer, resource, asset, options, &board);
|
||||
room = new Room(resource->getRoom(currentRoom), renderer, screen, asset, options, itemTracker, &board.items, false, debug);
|
||||
scoreboard = new ScoreBoard(renderer, resource, asset, &board);
|
||||
room = new Room(resource->getRoom(currentRoom), renderer, screen, asset, itemTracker, &board.items, false, debug);
|
||||
eventHandler = new SDL_Event();
|
||||
text = new Text(resource->getOffset("smb2.txt"), resource->getTexture("smb2.png"), renderer);
|
||||
|
||||
@@ -59,8 +58,8 @@ Demo::Demo(Resource *resource, options_t *options, section_t *section, Debug *de
|
||||
board.music = true;
|
||||
setScoreBoardColor();
|
||||
|
||||
section->name = SECTION_DEMO;
|
||||
section->subsection = 0;
|
||||
options.section.name = SECTION_DEMO;
|
||||
options.section.subsection = 0;
|
||||
}
|
||||
|
||||
Demo::~Demo()
|
||||
@@ -82,8 +81,8 @@ void Demo::checkEvents()
|
||||
// Evento de salida de la aplicación
|
||||
if (eventHandler->type == SDL_QUIT)
|
||||
{
|
||||
section->name = SECTION_QUIT;
|
||||
screen->setBorderColor(stringToColor(options->palette, "black"));
|
||||
options.section.name = SECTION_QUIT;
|
||||
screen->setBorderColor(stringToColor(options.palette, "black"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -95,7 +94,7 @@ void Demo::checkInput()
|
||||
|
||||
if (input->checkInput(input_exit, REPEAT_FALSE))
|
||||
{
|
||||
section->name = SECTION_QUIT;
|
||||
options.section.name = SECTION_QUIT;
|
||||
}
|
||||
|
||||
else if (input->checkInput(input_toggle_border, REPEAT_FALSE))
|
||||
@@ -129,15 +128,15 @@ void Demo::checkInput()
|
||||
|
||||
else if (input->checkInput(input_pause, REPEAT_FALSE) || input->checkInput(input_accept, REPEAT_FALSE) || input->checkInput(input_jump, REPEAT_FALSE))
|
||||
{
|
||||
section->name = SECTION_TITLE;
|
||||
section->subsection = 0;
|
||||
options.section.name = SECTION_TITLE;
|
||||
options.section.subsection = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Bucle para el juego
|
||||
void Demo::run()
|
||||
{
|
||||
while (section->name == SECTION_DEMO)
|
||||
while (options.section.name == SECTION_DEMO)
|
||||
{
|
||||
update();
|
||||
checkEvents();
|
||||
@@ -191,7 +190,7 @@ void Demo::renderRoomName()
|
||||
{
|
||||
// Texto en el centro de la pantalla
|
||||
SDL_Rect rect = {0, 16 * BLOCK, PLAY_AREA_WIDTH, BLOCK * 2};
|
||||
color_t color = stringToColor(options->palette, "white");
|
||||
color_t color = stringToColor(options.palette, "white");
|
||||
SDL_SetRenderDrawColor(renderer, color.r, color.g, color.b, 0xFF);
|
||||
SDL_RenderFillRect(renderer, &rect);
|
||||
|
||||
@@ -201,7 +200,7 @@ void Demo::renderRoomName()
|
||||
// Recarga todas las texturas
|
||||
void Demo::reLoadTextures()
|
||||
{
|
||||
if (options->console)
|
||||
if (options.console)
|
||||
{
|
||||
std::cout << "** RELOAD REQUESTED" << std::endl;
|
||||
}
|
||||
@@ -214,13 +213,13 @@ void Demo::reLoadTextures()
|
||||
void Demo::switchPalette()
|
||||
{
|
||||
// Modifica la variable
|
||||
if (options->palette == p_zxspectrum)
|
||||
if (options.palette == p_zxspectrum)
|
||||
{
|
||||
options->palette = p_zxarne;
|
||||
options.palette = p_zxarne;
|
||||
}
|
||||
else
|
||||
{
|
||||
options->palette = p_zxspectrum;
|
||||
options.palette = p_zxspectrum;
|
||||
}
|
||||
|
||||
room->reLoadPalette();
|
||||
@@ -243,7 +242,7 @@ bool Demo::changeRoom(std::string file)
|
||||
room = nullptr;
|
||||
|
||||
// Crea un objeto habitación nuevo a partir del fichero
|
||||
room = new Room(resource->getRoom(file), renderer, screen, asset, options, itemTracker, &board.items, false, debug);
|
||||
room = new Room(resource->getRoom(file), renderer, screen, asset, itemTracker, &board.items, false, debug);
|
||||
|
||||
// Pone el color del marcador en función del color del borde de la habitación
|
||||
setScoreBoardColor();
|
||||
@@ -264,8 +263,8 @@ void Demo::checkRoomChange()
|
||||
roomIndex++;
|
||||
if (roomIndex == (int)rooms.size())
|
||||
{
|
||||
section->name = SECTION_LOGO;
|
||||
section->subsection = SUBSECTION_LOGO_TO_TITLE;
|
||||
options.section.name = SECTION_LOGO;
|
||||
options.section.subsection = SUBSECTION_LOGO_TO_TITLE;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -281,10 +280,10 @@ void Demo::setScoreBoardColor()
|
||||
const color_t c = room->getBorderColor();
|
||||
|
||||
// Si el color es negro lo cambia a blanco
|
||||
const color_t cBlack = stringToColor(options->palette, "black");
|
||||
board.color = colorAreEqual(c, cBlack) ? stringToColor(options->palette, "white") : c;
|
||||
const color_t cBlack = stringToColor(options.palette, "black");
|
||||
board.color = colorAreEqual(c, cBlack) ? stringToColor(options.palette, "white") : c;
|
||||
|
||||
// Si el color es negro brillante lo cambia a blanco
|
||||
const color_t cBrightBlack = stringToColor(options->palette, "bright_black");
|
||||
board.color = colorAreEqual(c, cBrightBlack) ? stringToColor(options->palette, "white") : c;
|
||||
const color_t cBrightBlack = stringToColor(options.palette, "bright_black");
|
||||
board.color = colorAreEqual(c, cBrightBlack) ? stringToColor(options.palette, "white") : c;
|
||||
}
|
||||
Reference in New Issue
Block a user