Implementado el cambio de paleta durante el juego
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
@@ -27,6 +27,22 @@ color=yellow
|
|||||||
flip=true
|
flip=true
|
||||||
[/enemy]
|
[/enemy]
|
||||||
|
|
||||||
|
[enemy]
|
||||||
|
tileset=wave_v.png
|
||||||
|
animation=wave_v.ani
|
||||||
|
width=8
|
||||||
|
height=8
|
||||||
|
x=24
|
||||||
|
y=4
|
||||||
|
vx=0
|
||||||
|
vy=0.8
|
||||||
|
x1=24
|
||||||
|
y1=2
|
||||||
|
x2=24
|
||||||
|
y2=7
|
||||||
|
color=yellow
|
||||||
|
[/enemy]
|
||||||
|
|
||||||
[item]
|
[item]
|
||||||
tileset=items.png
|
tileset=items.png
|
||||||
tile=48
|
tile=48
|
||||||
@@ -34,3 +50,19 @@ x=7
|
|||||||
y=2
|
y=2
|
||||||
counter=1
|
counter=1
|
||||||
[/item]
|
[/item]
|
||||||
|
|
||||||
|
[item]
|
||||||
|
tileset=items.png
|
||||||
|
tile=48
|
||||||
|
x=1
|
||||||
|
y=14
|
||||||
|
counter=2
|
||||||
|
[/item]
|
||||||
|
|
||||||
|
[item]
|
||||||
|
tileset=items.png
|
||||||
|
tile=48
|
||||||
|
x=30
|
||||||
|
y=9
|
||||||
|
counter=3
|
||||||
|
[/item]
|
||||||
@@ -6,18 +6,18 @@
|
|||||||
32,32,32,32,0,0,0,0,32,32,67,68,67,68,67,68,67,68,67,68,67,68,67,68,67,68,67,68,67,68,67,68,
|
32,32,32,32,0,0,0,0,32,32,67,68,67,68,67,68,67,68,67,68,67,68,67,68,67,68,67,68,67,68,67,68,
|
||||||
32,32,0,0,0,0,0,0,0,0,91,92,91,92,91,92,91,92,91,92,91,92,91,92,91,92,91,92,91,92,91,92,
|
32,32,0,0,0,0,0,0,0,0,91,92,91,92,91,92,91,92,91,92,91,92,91,92,91,92,91,92,91,92,91,92,
|
||||||
93,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,93,
|
93,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,93,
|
||||||
117,0,0,0,403,403,403,403,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,117,
|
117,0,0,0,426,427,426,427,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,117,
|
||||||
117,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,117,
|
117,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,117,
|
||||||
117,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,117,
|
117,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,117,
|
||||||
141,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,117,
|
141,0,0,426,427,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,117,
|
||||||
32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,117,
|
32,0,0,0,426,427,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,117,
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,526,403,403,403,403,403,550,0,0,0,117,
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,526,403,403,403,403,403,550,0,0,0,117,
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,526,426,0,0,0,0,0,427,550,0,0,117,
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,526,0,0,0,0,0,0,0,550,0,0,117,
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,526,426,0,0,0,0,0,0,0,0,403,403,117,
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,526,0,0,0,0,0,0,0,0,0,403,403,117,
|
||||||
32,67,68,67,68,403,403,403,550,0,0,0,0,0,526,403,67,68,67,68,403,550,0,0,0,0,0,0,0,0,140,141,
|
32,67,68,67,68,403,403,403,403,403,403,0,0,0,526,67,68,67,68,67,68,67,68,0,0,0,0,0,0,0,140,141,
|
||||||
32,91,92,91,92,0,0,0,427,550,0,0,0,526,426,0,91,92,91,92,0,427,550,0,0,0,0,0,0,0,0,32,
|
32,91,92,91,92,0,0,0,0,0,0,0,0,526,0,91,92,91,92,91,92,91,92,0,0,0,0,0,0,0,0,32,
|
||||||
135,0,0,0,0,0,0,0,0,0,0,0,526,426,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
135,0,0,0,0,0,0,0,0,0,0,0,526,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
135,0,0,0,0,0,0,0,0,0,0,526,426,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
135,0,0,0,0,0,0,0,0,0,0,526,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
89,90,89,90,89,90,89,90,89,90,89,90,89,90,89,90,89,90,89,90,89,90,89,90,89,90,89,90,89,90,89,90
|
89,90,89,90,89,90,89,90,89,90,89,90,89,90,89,90,89,90,89,90,89,90,89,90,89,90,89,90,89,90,89,90
|
||||||
</data>
|
</data>
|
||||||
</layer>
|
</layer>
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 7.2 KiB After Width: | Height: | Size: 7.1 KiB |
|
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 8.6 KiB |
|
Before Width: | Height: | Size: 4.7 KiB After Width: | Height: | Size: 4.7 KiB |
BIN
data/title/loading_screen_bn_zxarne.png
Normal file
|
After Width: | Height: | Size: 4.7 KiB |
|
Before Width: | Height: | Size: 6.9 KiB After Width: | Height: | Size: 6.8 KiB |
BIN
data/title/loading_screen_color_zxarne.png
Normal file
|
After Width: | Height: | Size: 7.3 KiB |
@@ -291,7 +291,7 @@ void Screen::iniSpectrumFade()
|
|||||||
const std::vector<std::string> vColors = {"black", "blue", "red", "magenta", "green", "cyan", "yellow", "bright_white"};
|
const std::vector<std::string> vColors = {"black", "blue", "red", "magenta", "green", "cyan", "yellow", "bright_white"};
|
||||||
for (auto v : vColors)
|
for (auto v : vColors)
|
||||||
{
|
{
|
||||||
spectrumColor.push_back(stringToColor(v));
|
spectrumColor.push_back(stringToColor(options->palette, v));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -380,11 +380,9 @@ bool checkCollision(SDL_Point &p, d_line_t &l)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Devuelve un color_t a partir de un string
|
// Devuelve un color_t a partir de un string
|
||||||
color_t stringToColor(std::string str)
|
color_t stringToColor(palette_e pal, std::string str)
|
||||||
{
|
{
|
||||||
const std::string palette = "spectrum";
|
if (pal == p_zxspectrum)
|
||||||
|
|
||||||
if (palette == "spectrum")
|
|
||||||
{
|
{
|
||||||
if (str == "black")
|
if (str == "black")
|
||||||
{
|
{
|
||||||
@@ -467,7 +465,7 @@ color_t stringToColor(std::string str)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else if (pal == p_zxarne)
|
||||||
{ // zxarne
|
{ // zxarne
|
||||||
if (str == "black")
|
if (str == "black")
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -47,6 +47,13 @@ struct color_t
|
|||||||
Uint8 b;
|
Uint8 b;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Tipos de paleta
|
||||||
|
enum palette_e
|
||||||
|
{
|
||||||
|
p_zxspectrum,
|
||||||
|
p_zxarne
|
||||||
|
};
|
||||||
|
|
||||||
// Estructura para saber la seccion y subseccion del programa
|
// Estructura para saber la seccion y subseccion del programa
|
||||||
struct section_t
|
struct section_t
|
||||||
{
|
{
|
||||||
@@ -67,6 +74,7 @@ struct options_t
|
|||||||
bool keepAspect; // Indica si se ha de mantener la relación de aspecto al poner el modo a pantalla completa
|
bool keepAspect; // Indica si se ha de mantener la relación de aspecto al poner el modo a pantalla completa
|
||||||
bool borderEnabled; // Indica si ha de mostrar el borde en el modo de ventana
|
bool borderEnabled; // Indica si ha de mostrar el borde en el modo de ventana
|
||||||
float borderSize; // Porcentaje de borde que se añade a lo ventana
|
float borderSize; // Porcentaje de borde que se añade a lo ventana
|
||||||
|
palette_e palette; // Paleta de colores a usar en el juego
|
||||||
};
|
};
|
||||||
|
|
||||||
// Calcula el cuadrado de la distancia entre dos puntos
|
// Calcula el cuadrado de la distancia entre dos puntos
|
||||||
@@ -106,7 +114,7 @@ bool checkCollision(SDL_Point &p, d_line_t &l);
|
|||||||
void normalizeLine(d_line_t &l);
|
void normalizeLine(d_line_t &l);
|
||||||
|
|
||||||
// Devuelve un color_t a partir de un string
|
// Devuelve un color_t a partir de un string
|
||||||
color_t stringToColor(std::string str);
|
color_t stringToColor(palette_e pal, std::string str);
|
||||||
|
|
||||||
// Convierte una cadena en un valor booleano
|
// Convierte una cadena en un valor booleano
|
||||||
bool stringToBool(std::string str);
|
bool stringToBool(std::string str);
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
#include "credits.h"
|
#include "credits.h"
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Credits::Credits(SDL_Renderer *renderer, Screen *screen, Asset *asset)
|
Credits::Credits(SDL_Renderer *renderer, Screen *screen, Asset *asset, options_t *options)
|
||||||
{
|
{
|
||||||
// Copia la dirección de los objetos
|
// Copia la dirección de los objetos
|
||||||
this->renderer = renderer;
|
this->renderer = renderer;
|
||||||
this->screen = screen;
|
this->screen = screen;
|
||||||
this->asset = asset;
|
this->asset = asset;
|
||||||
|
this->options = options;
|
||||||
|
|
||||||
// Reserva memoria para los punteros
|
// Reserva memoria para los punteros
|
||||||
eventHandler = new SDL_Event();
|
eventHandler = new SDL_Event();
|
||||||
@@ -25,36 +26,36 @@ Credits::Credits(SDL_Renderer *renderer, Screen *screen, Asset *asset)
|
|||||||
sprite->setRect({194, 174, 8, 8});
|
sprite->setRect({194, 174, 8, 8});
|
||||||
|
|
||||||
// Cambia el color del borde
|
// Cambia el color del borde
|
||||||
screen->setBorderColor(stringToColor("black"));
|
screen->setBorderColor(stringToColor(options->palette, "black"));
|
||||||
|
|
||||||
// Inicializa los textos
|
// Inicializa los textos
|
||||||
texts.push_back({"", stringToColor("white")});
|
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||||
texts.push_back({"INSTRUCTIONS:", stringToColor("yellow")});
|
texts.push_back({"INSTRUCTIONS:", stringToColor(options->palette, "yellow")});
|
||||||
texts.push_back({"", stringToColor("white")});
|
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||||
texts.push_back({"HELP JAILDOC TO GET BACK ALL HIS", stringToColor("white")});
|
texts.push_back({"HELP JAILDOC TO GET BACK ALL HIS", stringToColor(options->palette, "white")});
|
||||||
texts.push_back({"PROJECTS AND GO TO THE JAIL TO", stringToColor("white")});
|
texts.push_back({"PROJECTS AND GO TO THE JAIL TO", stringToColor(options->palette, "white")});
|
||||||
texts.push_back({"FINISH THEM", stringToColor("white")});
|
texts.push_back({"FINISH THEM", stringToColor(options->palette, "white")});
|
||||||
texts.push_back({"", stringToColor("white")});
|
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||||
texts.push_back({"", stringToColor("white")});
|
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||||
|
|
||||||
texts.push_back({"KEYS:", stringToColor("yellow")});
|
texts.push_back({"KEYS:", stringToColor(options->palette, "yellow")});
|
||||||
texts.push_back({"", stringToColor("white")});
|
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||||
texts.push_back({"USE CURSORS TO MOVE AND JUMP", stringToColor("white")});
|
texts.push_back({"USE CURSORS TO MOVE AND JUMP", stringToColor(options->palette, "white")});
|
||||||
texts.push_back({"F1-F4 TO CHANGE WINDOWS SIZE", stringToColor("white")});
|
texts.push_back({"F1-F4 TO CHANGE WINDOWS SIZE", stringToColor(options->palette, "white")});
|
||||||
texts.push_back({"F TO SWITCH TO FULLSCREEN", stringToColor("white")});
|
texts.push_back({"F TO SWITCH TO FULLSCREEN", stringToColor(options->palette, "white")});
|
||||||
texts.push_back({"B TO DE/ACTIVATE THE BORDER SC.", stringToColor("white")});
|
texts.push_back({"B TO DE/ACTIVATE THE BORDER SC.", stringToColor(options->palette, "white")});
|
||||||
texts.push_back({"M TO TURN ON/OFF THE MUSIC", stringToColor("white")});
|
texts.push_back({"M TO TURN ON/OFF THE MUSIC", stringToColor(options->palette, "white")});
|
||||||
texts.push_back({"ESC TO EXIT GAME", stringToColor("white")});
|
texts.push_back({"ESC TO EXIT GAME", stringToColor(options->palette, "white")});
|
||||||
texts.push_back({"", stringToColor("white")});
|
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||||
texts.push_back({"", stringToColor("white")});
|
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||||
|
|
||||||
texts.push_back({"A GAME BY JAILDESIGNER", stringToColor("yellow")});
|
texts.push_back({"A GAME BY JAILDESIGNER", stringToColor(options->palette, "yellow")});
|
||||||
texts.push_back({"MADE ON SUMMER/FALL 2022", stringToColor("yellow")});
|
texts.push_back({"MADE ON SUMMER/FALL 2022", stringToColor(options->palette, "yellow")});
|
||||||
texts.push_back({"", stringToColor("white")});
|
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||||
texts.push_back({"", stringToColor("white")});
|
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||||
|
|
||||||
texts.push_back({"I LOVE JAILGAMES!}", stringToColor("white")});
|
texts.push_back({"I LOVE JAILGAMES!", stringToColor(options->palette, "white")});
|
||||||
texts.push_back({"", stringToColor("white")});
|
texts.push_back({"", stringToColor(options->palette, "white")});
|
||||||
|
|
||||||
// Crea la textura para el texto que se escribe en pantalla
|
// Crea la textura para el texto que se escribe en pantalla
|
||||||
textTexture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, GAMECANVAS_WIDTH, GAMECANVAS_HEIGHT);
|
textTexture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, GAMECANVAS_WIDTH, GAMECANVAS_HEIGHT);
|
||||||
@@ -124,7 +125,7 @@ void Credits::fillTexture()
|
|||||||
{
|
{
|
||||||
// Rellena la textura de texto
|
// Rellena la textura de texto
|
||||||
SDL_SetRenderTarget(renderer, textTexture);
|
SDL_SetRenderTarget(renderer, textTexture);
|
||||||
const color_t c = stringToColor("black");
|
const color_t c = stringToColor(options->palette, "black");
|
||||||
SDL_SetRenderDrawColor(renderer, c.r, c.g, c.b, 0x00);
|
SDL_SetRenderDrawColor(renderer, c.r, c.g, c.b, 0x00);
|
||||||
SDL_RenderClear(renderer);
|
SDL_RenderClear(renderer);
|
||||||
|
|
||||||
@@ -138,6 +139,9 @@ void Credits::fillTexture()
|
|||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Escribe el corazón
|
||||||
|
text->writeColored(194, 176, "}", stringToColor(options->palette, "bright_red"));
|
||||||
|
|
||||||
SDL_SetRenderTarget(renderer, nullptr);
|
SDL_SetRenderTarget(renderer, nullptr);
|
||||||
|
|
||||||
// Rellena la textura que cubre el texto
|
// Rellena la textura que cubre el texto
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ private:
|
|||||||
SDL_Texture *coverTexture; // Textura para cubrir el texto
|
SDL_Texture *coverTexture; // Textura para cubrir el texto
|
||||||
Texture *texture; // Textura para el sprite de brillo
|
Texture *texture; // Textura para el sprite de brillo
|
||||||
AnimatedSprite *sprite; // Sprite para el brillo del corazón
|
AnimatedSprite *sprite; // Sprite para el brillo del corazón
|
||||||
|
options_t *options; // Puntero a las opciones del juego
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
int counter; // Contador
|
int counter; // Contador
|
||||||
@@ -61,7 +62,7 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
Credits(SDL_Renderer *renderer, Screen *screen, Asset *asset);
|
Credits(SDL_Renderer *renderer, Screen *screen, Asset *asset, options_t *options);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~Credits();
|
~Credits();
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#include "demo.h"
|
#include "demo.h"
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Demo::Demo(SDL_Renderer *renderer, Screen *screen, Asset *asset, Debug *debug)
|
Demo::Demo(SDL_Renderer *renderer, Screen *screen, Asset *asset, options_t *options, Debug *debug)
|
||||||
{
|
{
|
||||||
// Inicia algunas variables
|
// Inicia algunas variables
|
||||||
board.iniClock = SDL_GetTicks();
|
board.iniClock = SDL_GetTicks();
|
||||||
@@ -19,11 +19,12 @@ Demo::Demo(SDL_Renderer *renderer, Screen *screen, Asset *asset, Debug *debug)
|
|||||||
this->asset = asset;
|
this->asset = asset;
|
||||||
this->screen = screen;
|
this->screen = screen;
|
||||||
this->debug = debug;
|
this->debug = debug;
|
||||||
|
this->options = options;
|
||||||
|
|
||||||
// Crea los objetos
|
// Crea los objetos
|
||||||
itemTracker = new ItemTracker();
|
itemTracker = new ItemTracker();
|
||||||
scoreboard = new ScoreBoard(renderer, asset, &board);
|
scoreboard = new ScoreBoard(renderer, asset, options, &board);
|
||||||
room = new Room(asset->get(currentRoom), renderer, screen, asset, itemTracker, &board.items, debug);
|
room = new Room(asset->get(currentRoom), renderer, screen, asset, options, itemTracker, &board.items, debug);
|
||||||
eventHandler = new SDL_Event();
|
eventHandler = new SDL_Event();
|
||||||
text = new Text(asset->get("smb2.png"), asset->get("smb2.txt"), renderer);
|
text = new Text(asset->get("smb2.png"), asset->get("smb2.txt"), renderer);
|
||||||
|
|
||||||
@@ -35,7 +36,7 @@ Demo::Demo(SDL_Renderer *renderer, Screen *screen, Asset *asset, Debug *debug)
|
|||||||
board.items = 0;
|
board.items = 0;
|
||||||
board.rooms = 1;
|
board.rooms = 1;
|
||||||
const color_t c = room->getBorderColor();
|
const color_t c = room->getBorderColor();
|
||||||
board.color = (c.r + c.g + c.b == 0) ? stringToColor("white") : c; // Si el color es negro lo cambia a blanco
|
board.color = (c.r + c.g + c.b == 0) ? stringToColor(options->palette, "white") : c; // Si el color es negro lo cambia a blanco
|
||||||
|
|
||||||
board.music = !debug->getEnabled();
|
board.music = !debug->getEnabled();
|
||||||
|
|
||||||
@@ -63,7 +64,7 @@ void Demo::checkEventHandler()
|
|||||||
if (eventHandler->type == SDL_QUIT)
|
if (eventHandler->type == SDL_QUIT)
|
||||||
{
|
{
|
||||||
section.name = SECTION_PROG_QUIT;
|
section.name = SECTION_PROG_QUIT;
|
||||||
screen->setBorderColor(stringToColor("black"));
|
screen->setBorderColor(stringToColor(options->palette, "black"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if ((eventHandler->type == SDL_KEYDOWN) and (eventHandler->key.repeat == 0))
|
else if ((eventHandler->type == SDL_KEYDOWN) and (eventHandler->key.repeat == 0))
|
||||||
@@ -163,7 +164,7 @@ void Demo::renderRoomName()
|
|||||||
{
|
{
|
||||||
// Texto en el centro de la pantalla
|
// Texto en el centro de la pantalla
|
||||||
SDL_Rect rect = {0, 16 * BLOCK, PLAY_AREA_WIDTH, BLOCK * 2};
|
SDL_Rect rect = {0, 16 * BLOCK, PLAY_AREA_WIDTH, BLOCK * 2};
|
||||||
color_t color = stringToColor("white");
|
color_t color = stringToColor(options->palette, "white");
|
||||||
SDL_SetRenderDrawColor(renderer, color.r, color.g, color.b, 0xFF);
|
SDL_SetRenderDrawColor(renderer, color.r, color.g, color.b, 0xFF);
|
||||||
SDL_RenderFillRect(renderer, &rect);
|
SDL_RenderFillRect(renderer, &rect);
|
||||||
|
|
||||||
@@ -191,11 +192,11 @@ bool Demo::changeRoom(std::string file)
|
|||||||
room = nullptr;
|
room = nullptr;
|
||||||
|
|
||||||
// Crea un objeto habitación nuevo a partir del fichero
|
// Crea un objeto habitación nuevo a partir del fichero
|
||||||
room = new Room(asset->get(file), renderer, screen, asset, itemTracker, &board.items, debug);
|
room = new Room(asset->get(file), renderer, screen, asset, options, itemTracker, &board.items, debug);
|
||||||
|
|
||||||
// Actualiza el marcador
|
// Actualiza el marcador
|
||||||
const color_t c = room->getBorderColor(); // Pone el color del marcador
|
const color_t c = room->getBorderColor(); // Pone el color del marcador
|
||||||
board.color = (c.r + c.g + c.b == 0) ? stringToColor("white") : c; // Si el color es negro lo cambia a blanco
|
board.color = (c.r + c.g + c.b == 0) ? stringToColor(options->palette, "white") : c; // Si el color es negro lo cambia a blanco
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ private:
|
|||||||
ScoreBoard *scoreboard; // Objeto encargado de gestionar el marcador
|
ScoreBoard *scoreboard; // Objeto encargado de gestionar el marcador
|
||||||
ItemTracker *itemTracker; // Lleva el control de los objetos recogidos
|
ItemTracker *itemTracker; // Lleva el control de los objetos recogidos
|
||||||
Debug *debug; // Objeto para gestionar la información de debug
|
Debug *debug; // Objeto para gestionar la información de debug
|
||||||
|
options_t *options; // Puntero a las opciones del juego
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
|
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
|
||||||
@@ -65,7 +66,7 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
Demo(SDL_Renderer *renderer, Screen *screen, Asset *asset, Debug *debug);
|
Demo(SDL_Renderer *renderer, Screen *screen, Asset *asset, options_t *options, Debug *debug);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~Demo();
|
~Demo();
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ Director::Director(std::string path)
|
|||||||
section.name = SECTION_PROG_LOGO;
|
section.name = SECTION_PROG_LOGO;
|
||||||
section.subsection = SUBSECTION_LOGO_TO_INTRO;
|
section.subsection = SUBSECTION_LOGO_TO_INTRO;
|
||||||
|
|
||||||
section.name = SECTION_PROG_CREDITS;
|
section.name = SECTION_PROG_LOGO;
|
||||||
|
|
||||||
// Crea el objeto que controla los ficheros de recursos
|
// Crea el objeto que controla los ficheros de recursos
|
||||||
asset = new Asset(path.substr(0, path.find_last_of("\\/")));
|
asset = new Asset(path.substr(0, path.find_last_of("\\/")));
|
||||||
@@ -70,6 +70,7 @@ bool Director::loadConfig()
|
|||||||
options->keepAspect = true;
|
options->keepAspect = true;
|
||||||
options->borderEnabled = true;
|
options->borderEnabled = true;
|
||||||
options->borderSize = 0.1f;
|
options->borderSize = 0.1f;
|
||||||
|
options->palette = p_zxspectrum;
|
||||||
|
|
||||||
// Indicador de éxito en la carga
|
// Indicador de éxito en la carga
|
||||||
bool success = true;
|
bool success = true;
|
||||||
@@ -167,6 +168,7 @@ bool Director::saveConfig()
|
|||||||
file << "keepAspect=" + boolToString(options->keepAspect) + "\n";
|
file << "keepAspect=" + boolToString(options->keepAspect) + "\n";
|
||||||
file << "borderEnabled=" + boolToString(options->borderEnabled) + "\n";
|
file << "borderEnabled=" + boolToString(options->borderEnabled) + "\n";
|
||||||
file << "borderSize=" + std::to_string(options->borderSize) + "\n";
|
file << "borderSize=" + std::to_string(options->borderSize) + "\n";
|
||||||
|
file << "palette=" + std::to_string(options->palette) + "\n";
|
||||||
|
|
||||||
// Cierra el fichero
|
// Cierra el fichero
|
||||||
file.close();
|
file.close();
|
||||||
@@ -246,6 +248,21 @@ bool Director::setOptions(options_t *options, std::string var, std::string value
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
else if (var == "palette")
|
||||||
|
{
|
||||||
|
const int pal = std::stoi(value);
|
||||||
|
|
||||||
|
if (pal == 0)
|
||||||
|
{
|
||||||
|
options->palette = p_zxspectrum;
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (pal == 1)
|
||||||
|
{
|
||||||
|
options->palette = p_zxarne;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
else if (var == "")
|
else if (var == "")
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -623,6 +640,8 @@ bool Director::setFileList()
|
|||||||
// Intro
|
// Intro
|
||||||
asset->add("/data/title/loading_screen_bn.png", t_bitmap);
|
asset->add("/data/title/loading_screen_bn.png", t_bitmap);
|
||||||
asset->add("/data/title/loading_screen_color.png", t_bitmap);
|
asset->add("/data/title/loading_screen_color.png", t_bitmap);
|
||||||
|
asset->add("/data/title/loading_screen_bn_zxarne.png", t_bitmap);
|
||||||
|
asset->add("/data/title/loading_screen_color_zxarne.png", t_bitmap);
|
||||||
|
|
||||||
// Credits
|
// Credits
|
||||||
asset->add("/data/credits/shine.png", t_bitmap);
|
asset->add("/data/credits/shine.png", t_bitmap);
|
||||||
@@ -652,7 +671,7 @@ void Director::setSection(section_t section)
|
|||||||
// Ejecuta la seccion de juego con el logo
|
// Ejecuta la seccion de juego con el logo
|
||||||
void Director::runLogo()
|
void Director::runLogo()
|
||||||
{
|
{
|
||||||
logo = new Logo(renderer, screen, asset, section.subsection);
|
logo = new Logo(renderer, screen, asset, options, section.subsection);
|
||||||
setSection(logo->run());
|
setSection(logo->run());
|
||||||
delete logo;
|
delete logo;
|
||||||
}
|
}
|
||||||
@@ -660,7 +679,7 @@ void Director::runLogo()
|
|||||||
// Ejecuta la seccion de juego de la introducción
|
// Ejecuta la seccion de juego de la introducción
|
||||||
void Director::runIntro()
|
void Director::runIntro()
|
||||||
{
|
{
|
||||||
intro = new Intro(renderer, screen, asset);
|
intro = new Intro(renderer, screen, asset, options);
|
||||||
setSection(intro->run());
|
setSection(intro->run());
|
||||||
delete intro;
|
delete intro;
|
||||||
}
|
}
|
||||||
@@ -672,7 +691,7 @@ void Director::runTitle()
|
|||||||
{
|
{
|
||||||
JA_PlayMusic(music);
|
JA_PlayMusic(music);
|
||||||
}
|
}
|
||||||
title = new Title(renderer, screen, asset);
|
title = new Title(renderer, screen, asset, options);
|
||||||
setSection(title->run());
|
setSection(title->run());
|
||||||
delete title;
|
delete title;
|
||||||
}
|
}
|
||||||
@@ -680,7 +699,7 @@ void Director::runTitle()
|
|||||||
// Ejecuta la seccion de los creditos del juego
|
// Ejecuta la seccion de los creditos del juego
|
||||||
void Director::runCredits()
|
void Director::runCredits()
|
||||||
{
|
{
|
||||||
credits = new Credits(renderer, screen, asset);
|
credits = new Credits(renderer, screen, asset, options);
|
||||||
setSection(credits->run());
|
setSection(credits->run());
|
||||||
delete credits;
|
delete credits;
|
||||||
}
|
}
|
||||||
@@ -688,7 +707,7 @@ void Director::runCredits()
|
|||||||
// Ejecuta la seccion de la demo, donde se ven pantallas del juego
|
// Ejecuta la seccion de la demo, donde se ven pantallas del juego
|
||||||
void Director::runDemo()
|
void Director::runDemo()
|
||||||
{
|
{
|
||||||
demo = new Demo(renderer, screen, asset, debug);
|
demo = new Demo(renderer, screen, asset, options, debug);
|
||||||
setSection(demo->run());
|
setSection(demo->run());
|
||||||
delete demo;
|
delete demo;
|
||||||
}
|
}
|
||||||
@@ -697,7 +716,7 @@ void Director::runDemo()
|
|||||||
void Director::runGame()
|
void Director::runGame()
|
||||||
{
|
{
|
||||||
JA_StopMusic();
|
JA_StopMusic();
|
||||||
game = new Game(renderer, screen, asset, input, debug);
|
game = new Game(renderer, screen, asset, options, input, debug);
|
||||||
setSection(game->run());
|
setSection(game->run());
|
||||||
delete game;
|
delete game;
|
||||||
}
|
}
|
||||||
@@ -712,18 +731,23 @@ void Director::run()
|
|||||||
case SECTION_PROG_LOGO:
|
case SECTION_PROG_LOGO:
|
||||||
runLogo();
|
runLogo();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SECTION_PROG_INTRO:
|
case SECTION_PROG_INTRO:
|
||||||
runIntro();
|
runIntro();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SECTION_PROG_TITLE:
|
case SECTION_PROG_TITLE:
|
||||||
runTitle();
|
runTitle();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SECTION_PROG_CREDITS:
|
case SECTION_PROG_CREDITS:
|
||||||
runCredits();
|
runCredits();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SECTION_PROG_DEMO:
|
case SECTION_PROG_DEMO:
|
||||||
runDemo();
|
runDemo();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SECTION_PROG_GAME:
|
case SECTION_PROG_GAME:
|
||||||
runGame();
|
runGame();
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#include "game.h"
|
#include "game.h"
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Game::Game(SDL_Renderer *renderer, Screen *screen, Asset *asset, Input *input, Debug *debug)
|
Game::Game(SDL_Renderer *renderer, Screen *screen, Asset *asset, options_t *options, Input *input, Debug *debug)
|
||||||
{
|
{
|
||||||
// Inicia algunas variables
|
// Inicia algunas variables
|
||||||
board.iniClock = SDL_GetTicks();
|
board.iniClock = SDL_GetTicks();
|
||||||
@@ -14,6 +14,7 @@ Game::Game(SDL_Renderer *renderer, Screen *screen, Asset *asset, Input *input, D
|
|||||||
this->screen = screen;
|
this->screen = screen;
|
||||||
this->input = input;
|
this->input = input;
|
||||||
this->debug = debug;
|
this->debug = debug;
|
||||||
|
this->options = options;
|
||||||
|
|
||||||
// ****
|
// ****
|
||||||
// this->debug->setEnabled(true);
|
// this->debug->setEnabled(true);
|
||||||
@@ -24,11 +25,11 @@ Game::Game(SDL_Renderer *renderer, Screen *screen, Asset *asset, Input *input, D
|
|||||||
// ****
|
// ****
|
||||||
|
|
||||||
// Crea los objetos
|
// Crea los objetos
|
||||||
scoreboard = new ScoreBoard(renderer, asset, &board);
|
scoreboard = new ScoreBoard(renderer, asset, options, &board);
|
||||||
itemTracker = new ItemTracker();
|
itemTracker = new ItemTracker();
|
||||||
roomTracker = new RoomTracker();
|
roomTracker = new RoomTracker();
|
||||||
room = new Room(asset->get(currentRoom), renderer, screen, asset, itemTracker, &board.items, debug);
|
room = new Room(asset->get(currentRoom), renderer, screen, asset, options, itemTracker, &board.items, debug);
|
||||||
player = new Player(spawnPoint, asset->get("player.png"), asset->get("player.ani"), renderer, asset, input, room, debug);
|
player = new Player(spawnPoint, asset->get("player.png"), asset->get("player.ani"), renderer, asset, options, input, room, debug);
|
||||||
eventHandler = new SDL_Event();
|
eventHandler = new SDL_Event();
|
||||||
text = new Text(asset->get("smb2.png"), asset->get("smb2.txt"), renderer);
|
text = new Text(asset->get("smb2.png"), asset->get("smb2.txt"), renderer);
|
||||||
music = JA_LoadMusic(asset->get("game.ogg").c_str());
|
music = JA_LoadMusic(asset->get("game.ogg").c_str());
|
||||||
@@ -42,7 +43,7 @@ Game::Game(SDL_Renderer *renderer, Screen *screen, Asset *asset, Input *input, D
|
|||||||
board.items = 0;
|
board.items = 0;
|
||||||
board.rooms = 1;
|
board.rooms = 1;
|
||||||
const color_t c = room->getBorderColor();
|
const color_t c = room->getBorderColor();
|
||||||
board.color = (c.r + c.g + c.b == 0) ? stringToColor("white") : c; // Si el color es negro lo cambia a blanco
|
board.color = (c.r + c.g + c.b == 0) ? stringToColor(options->palette, "white") : c; // Si el color es negro lo cambia a blanco
|
||||||
roomTracker->addRoom(currentRoom);
|
roomTracker->addRoom(currentRoom);
|
||||||
paused = false;
|
paused = false;
|
||||||
blackScreen = false;
|
blackScreen = false;
|
||||||
@@ -82,7 +83,7 @@ void Game::checkEventHandler()
|
|||||||
if (eventHandler->type == SDL_QUIT)
|
if (eventHandler->type == SDL_QUIT)
|
||||||
{
|
{
|
||||||
section.name = SECTION_PROG_QUIT;
|
section.name = SECTION_PROG_QUIT;
|
||||||
screen->setBorderColor(stringToColor("black"));
|
screen->setBorderColor(stringToColor(options->palette, "black"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if ((eventHandler->type == SDL_KEYDOWN) and (eventHandler->key.repeat == 0))
|
else if ((eventHandler->type == SDL_KEYDOWN) and (eventHandler->key.repeat == 0))
|
||||||
@@ -152,6 +153,18 @@ void Game::checkEventHandler()
|
|||||||
reLoadTextures();
|
reLoadTextures();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case SDL_SCANCODE_F5:
|
||||||
|
if (options->palette == p_zxspectrum)
|
||||||
|
{
|
||||||
|
options->palette = p_zxarne;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
options->palette = p_zxspectrum;
|
||||||
|
}
|
||||||
|
reLoadTextures();
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -273,7 +286,7 @@ void Game::renderRoomName()
|
|||||||
{
|
{
|
||||||
// Texto en el centro de la pantalla
|
// Texto en el centro de la pantalla
|
||||||
SDL_Rect rect = {0, 16 * BLOCK, PLAY_AREA_WIDTH, BLOCK * 2};
|
SDL_Rect rect = {0, 16 * BLOCK, PLAY_AREA_WIDTH, BLOCK * 2};
|
||||||
color_t color = stringToColor("white");
|
color_t color = stringToColor(options->palette, "white");
|
||||||
SDL_SetRenderDrawColor(renderer, color.r, color.g, color.b, 0xFF);
|
SDL_SetRenderDrawColor(renderer, color.r, color.g, color.b, 0xFF);
|
||||||
SDL_RenderFillRect(renderer, &rect);
|
SDL_RenderFillRect(renderer, &rect);
|
||||||
|
|
||||||
@@ -293,11 +306,11 @@ bool Game::changeRoom(std::string file)
|
|||||||
room = nullptr;
|
room = nullptr;
|
||||||
|
|
||||||
// Crea un objeto habitación nuevo a partir del fichero
|
// Crea un objeto habitación nuevo a partir del fichero
|
||||||
room = new Room(asset->get(file), renderer, screen, asset, itemTracker, &board.items, debug);
|
room = new Room(asset->get(file), renderer, screen, asset, options, itemTracker, &board.items, debug);
|
||||||
|
|
||||||
// Actualiza el marcador
|
// Actualiza el marcador
|
||||||
const color_t c = room->getBorderColor(); // Pone el color del marcador
|
const color_t c = room->getBorderColor(); // Pone el color del marcador
|
||||||
board.color = (c.r + c.g + c.b == 0) ? stringToColor("white") : c; // Si el color es negro lo cambia a blanco
|
board.color = (c.r + c.g + c.b == 0) ? stringToColor(options->palette, "white") : c; // Si el color es negro lo cambia a blanco
|
||||||
if (roomTracker->addRoom(file))
|
if (roomTracker->addRoom(file))
|
||||||
{ // Incrementa el contador de habitaciones visitadas
|
{ // Incrementa el contador de habitaciones visitadas
|
||||||
board.rooms++;
|
board.rooms++;
|
||||||
@@ -382,8 +395,8 @@ void Game::killPlayer()
|
|||||||
setBlackScreen();
|
setBlackScreen();
|
||||||
|
|
||||||
// Crea la nueva habitación y el nuevo jugador
|
// Crea la nueva habitación y el nuevo jugador
|
||||||
room = new Room(asset->get(currentRoom), renderer, screen, asset, itemTracker, &board.items, debug);
|
room = new Room(asset->get(currentRoom), renderer, screen, asset, options, itemTracker, &board.items, debug);
|
||||||
player = new Player(spawnPoint, asset->get("player.png"), asset->get("player.ani"), renderer, asset, input, room, debug);
|
player = new Player(spawnPoint, asset->get("player.png"), asset->get("player.ani"), renderer, asset, options, input, room, debug);
|
||||||
|
|
||||||
room->pause();
|
room->pause();
|
||||||
player->pause();
|
player->pause();
|
||||||
@@ -428,6 +441,6 @@ void Game::renderBlackScreen()
|
|||||||
if (blackScreen)
|
if (blackScreen)
|
||||||
{
|
{
|
||||||
screen->clean();
|
screen->clean();
|
||||||
screen->setBorderColor(stringToColor("black"));
|
screen->setBorderColor(stringToColor(options->palette, "black"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -37,6 +37,7 @@ private:
|
|||||||
Text *text; // Objeto para los textos del juego
|
Text *text; // Objeto para los textos del juego
|
||||||
ScoreBoard *scoreboard; // Objeto encargado de gestionar el marcador
|
ScoreBoard *scoreboard; // Objeto encargado de gestionar el marcador
|
||||||
Debug *debug; // Objeto para gestionar la información de debug
|
Debug *debug; // Objeto para gestionar la información de debug
|
||||||
|
options_t *options; // Puntero a las opciones del juego
|
||||||
Test *test;
|
Test *test;
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
@@ -105,7 +106,7 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
Game(SDL_Renderer *renderer, Screen *screen, Asset *asset, Input *input, Debug *debug);
|
Game(SDL_Renderer *renderer, Screen *screen, Asset *asset, options_t *options, Input *input, Debug *debug);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~Game();
|
~Game();
|
||||||
|
|||||||
@@ -1,17 +1,26 @@
|
|||||||
#include "intro.h"
|
#include "intro.h"
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Intro::Intro(SDL_Renderer *renderer, Screen *screen, Asset *asset)
|
Intro::Intro(SDL_Renderer *renderer, Screen *screen, Asset *asset, options_t *options)
|
||||||
{
|
{
|
||||||
// Copia la dirección de los objetos
|
// Copia la dirección de los objetos
|
||||||
this->renderer = renderer;
|
this->renderer = renderer;
|
||||||
this->screen = screen;
|
this->screen = screen;
|
||||||
this->asset = asset;
|
this->asset = asset;
|
||||||
|
this->options = options;
|
||||||
|
|
||||||
// Reserva memoria para los punteros
|
// Reserva memoria para los punteros
|
||||||
eventHandler = new SDL_Event();
|
eventHandler = new SDL_Event();
|
||||||
|
if (options->palette == p_zxspectrum)
|
||||||
|
{
|
||||||
loadingScreenTexture1 = new Texture(renderer, asset->get("loading_screen_bn.png"));
|
loadingScreenTexture1 = new Texture(renderer, asset->get("loading_screen_bn.png"));
|
||||||
loadingScreenTexture2 = new Texture(renderer, asset->get("loading_screen_color.png"));
|
loadingScreenTexture2 = new Texture(renderer, asset->get("loading_screen_color.png"));
|
||||||
|
}
|
||||||
|
else if (options->palette == p_zxarne)
|
||||||
|
{
|
||||||
|
loadingScreenTexture1 = new Texture(renderer, asset->get("loading_screen_bn_zxarne.png"));
|
||||||
|
loadingScreenTexture2 = new Texture(renderer, asset->get("loading_screen_color_zxarne.png"));
|
||||||
|
}
|
||||||
sprite1 = new Sprite(0, 0, loadingScreenTexture1->getWidth(), loadingScreenTexture1->getHeight(), loadingScreenTexture1, renderer);
|
sprite1 = new Sprite(0, 0, loadingScreenTexture1->getWidth(), loadingScreenTexture1->getHeight(), loadingScreenTexture1, renderer);
|
||||||
sprite2 = new Sprite(0, 0, loadingScreenTexture2->getWidth(), loadingScreenTexture2->getHeight(), loadingScreenTexture2, renderer);
|
sprite2 = new Sprite(0, 0, loadingScreenTexture2->getWidth(), loadingScreenTexture2->getHeight(), loadingScreenTexture2, renderer);
|
||||||
loadingSound1 = JA_LoadMusic(asset->get("loading_sound1.ogg").c_str());
|
loadingSound1 = JA_LoadMusic(asset->get("loading_sound1.ogg").c_str());
|
||||||
@@ -57,7 +66,7 @@ Intro::Intro(SDL_Renderer *renderer, Screen *screen, Asset *asset)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Cambia el color del borde
|
// Cambia el color del borde
|
||||||
screen->setBorderColor(stringToColor("black"));
|
screen->setBorderColor(stringToColor(options->palette, "black"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ private:
|
|||||||
SDL_Event *eventHandler; // Manejador de eventos
|
SDL_Event *eventHandler; // Manejador de eventos
|
||||||
Sprite *sprite1; // Sprite para manejar la textura loadingScreenTexture1
|
Sprite *sprite1; // Sprite para manejar la textura loadingScreenTexture1
|
||||||
Sprite *sprite2; // Sprite para manejar la textura loadingScreenTexture2
|
Sprite *sprite2; // Sprite para manejar la textura loadingScreenTexture2
|
||||||
|
options_t *options; // Puntero a las opciones del juego
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
int preCounter; // Contador previo para realizar una pausa inicial
|
int preCounter; // Contador previo para realizar una pausa inicial
|
||||||
@@ -63,7 +64,7 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
Intro(SDL_Renderer *renderer, Screen *screen, Asset *asset);
|
Intro(SDL_Renderer *renderer, Screen *screen, Asset *asset, options_t *options);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~Intro();
|
~Intro();
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
#include "logo.h"
|
#include "logo.h"
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Logo::Logo(SDL_Renderer *renderer, Screen *screen, Asset *asset, int subsection)
|
Logo::Logo(SDL_Renderer *renderer, Screen *screen, Asset *asset, options_t *options, int subsection)
|
||||||
{
|
{
|
||||||
// Copia la dirección de los objetos
|
// Copia la dirección de los objetos
|
||||||
this->renderer = renderer;
|
this->renderer = renderer;
|
||||||
this->screen = screen;
|
this->screen = screen;
|
||||||
this->asset = asset;
|
this->asset = asset;
|
||||||
|
this->options = options;
|
||||||
|
|
||||||
// Reserva memoria para los punteros
|
// Reserva memoria para los punteros
|
||||||
eventHandler = new SDL_Event();
|
eventHandler = new SDL_Event();
|
||||||
@@ -21,13 +22,13 @@ Logo::Logo(SDL_Renderer *renderer, Screen *screen, Asset *asset, int subsection)
|
|||||||
sprite.push_back(new Sprite(0, i, texture->getWidth(), 1, texture, renderer));
|
sprite.push_back(new Sprite(0, i, texture->getWidth(), 1, texture, renderer));
|
||||||
if (i % 2 == 0)
|
if (i % 2 == 0)
|
||||||
{
|
{
|
||||||
sprite[i]->setPosX(256 + (i * 3));
|
sprite.at(i)->setPosX(256 + (i * 3));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sprite[i]->setPosX(-181 - (i * 3));
|
sprite.at(i)->setPosX(-181 - (i * 3));
|
||||||
}
|
}
|
||||||
sprite[i]->setPosY(83 + i);
|
sprite.at(i)->setPosY(83 + i);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Inicializa variables
|
// Inicializa variables
|
||||||
@@ -44,11 +45,11 @@ Logo::Logo(SDL_Renderer *renderer, Screen *screen, Asset *asset, int subsection)
|
|||||||
const std::vector<std::string> vColors = {"black", "blue", "red", "magenta", "green", "cyan", "yellow", "bright_white"};
|
const std::vector<std::string> vColors = {"black", "blue", "red", "magenta", "green", "cyan", "yellow", "bright_white"};
|
||||||
for (auto v : vColors)
|
for (auto v : vColors)
|
||||||
{
|
{
|
||||||
color.push_back(stringToColor(v));
|
color.push_back(stringToColor(options->palette, v));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cambia el color del borde
|
// Cambia el color del borde
|
||||||
screen->setBorderColor(stringToColor("black"));
|
screen->setBorderColor(stringToColor(options->palette, "black"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
@@ -97,22 +98,22 @@ void Logo::updateJAILGAMES()
|
|||||||
{
|
{
|
||||||
const int speed = 8;
|
const int speed = 8;
|
||||||
const int dest = 37;
|
const int dest = 37;
|
||||||
if (sprite[i]->getPosX() != 37)
|
if (sprite.at(i)->getPosX() != 37)
|
||||||
{
|
{
|
||||||
if (i % 2 == 0)
|
if (i % 2 == 0)
|
||||||
{
|
{
|
||||||
sprite[i]->incPosX(-speed);
|
sprite.at(i)->incPosX(-speed);
|
||||||
if (sprite[i]->getPosX() < dest)
|
if (sprite.at(i)->getPosX() < dest)
|
||||||
{
|
{
|
||||||
sprite[i]->setPosX(dest);
|
sprite.at(i)->setPosX(dest);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sprite[i]->incPosX(speed);
|
sprite.at(i)->incPosX(speed);
|
||||||
if (sprite[i]->getPosX() > dest)
|
if (sprite.at(i)->getPosX() > dest)
|
||||||
{
|
{
|
||||||
sprite[i]->setPosX(dest);
|
sprite.at(i)->setPosX(dest);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -128,72 +129,72 @@ void Logo::updateTextureColors()
|
|||||||
|
|
||||||
if (counter == ini + inc * 0)
|
if (counter == ini + inc * 0)
|
||||||
{
|
{
|
||||||
texture2->setColor(color[0].r, color[0].g, color[0].b);
|
texture2->setColor(color.at(0).r, color.at(0).g, color.at(0).b);
|
||||||
}
|
}
|
||||||
else if (counter == ini + inc * 1)
|
else if (counter == ini + inc * 1)
|
||||||
{
|
{
|
||||||
texture2->setColor(color[1].r, color[1].g, color[1].b);
|
texture2->setColor(color.at(1).r, color.at(1).g, color.at(1).b);
|
||||||
}
|
}
|
||||||
else if (counter == ini + inc * 2)
|
else if (counter == ini + inc * 2)
|
||||||
{
|
{
|
||||||
texture2->setColor(color[2].r, color[2].g, color[2].b);
|
texture2->setColor(color.at(2).r, color.at(2).g, color.at(2).b);
|
||||||
}
|
}
|
||||||
else if (counter == ini + inc * 3)
|
else if (counter == ini + inc * 3)
|
||||||
{
|
{
|
||||||
texture2->setColor(color[3].r, color[3].g, color[3].b);
|
texture2->setColor(color.at(3).r, color.at(3).g, color.at(3).b);
|
||||||
}
|
}
|
||||||
else if (counter == ini + inc * 4)
|
else if (counter == ini + inc * 4)
|
||||||
{
|
{
|
||||||
texture2->setColor(color[4].r, color[4].g, color[4].b);
|
texture2->setColor(color.at(4).r, color.at(4).g, color.at(4).b);
|
||||||
}
|
}
|
||||||
else if (counter == ini + inc * 5)
|
else if (counter == ini + inc * 5)
|
||||||
{
|
{
|
||||||
texture2->setColor(color[5].r, color[5].g, color[5].b);
|
texture2->setColor(color.at(5).r, color.at(5).g, color.at(5).b);
|
||||||
}
|
}
|
||||||
else if (counter == ini + inc * 6)
|
else if (counter == ini + inc * 6)
|
||||||
{
|
{
|
||||||
texture2->setColor(color[6].r, color[6].g, color[6].b);
|
texture2->setColor(color.at(6).r, color.at(6).g, color.at(6).b);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (counter == ini + inc * 7)
|
else if (counter == ini + inc * 7)
|
||||||
{
|
{
|
||||||
texture2->setColor(color[7].r, color[7].g, color[7].b);
|
texture2->setColor(color.at(7).r, color.at(7).g, color.at(7).b);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (counter == initFade + inc * 0)
|
else if (counter == initFade + inc * 0)
|
||||||
{
|
{
|
||||||
texture->setColor(color[6].r, color[6].g, color[6].b);
|
texture->setColor(color.at(6).r, color.at(6).g, color.at(6).b);
|
||||||
texture2->setColor(color[6].r, color[6].g, color[6].b);
|
texture2->setColor(color.at(6).r, color.at(6).g, color.at(6).b);
|
||||||
}
|
}
|
||||||
else if (counter == initFade + inc * 1)
|
else if (counter == initFade + inc * 1)
|
||||||
{
|
{
|
||||||
texture->setColor(color[5].r, color[5].g, color[5].b);
|
texture->setColor(color.at(5).r, color.at(5).g, color.at(5).b);
|
||||||
texture2->setColor(color[5].r, color[5].g, color[5].b);
|
texture2->setColor(color.at(5).r, color.at(5).g, color.at(5).b);
|
||||||
}
|
}
|
||||||
else if (counter == initFade + inc * 2)
|
else if (counter == initFade + inc * 2)
|
||||||
{
|
{
|
||||||
texture->setColor(color[4].r, color[4].g, color[4].b);
|
texture->setColor(color.at(4).r, color.at(4).g, color.at(4).b);
|
||||||
texture2->setColor(color[4].r, color[4].g, color[4].b);
|
texture2->setColor(color.at(4).r, color.at(4).g, color.at(4).b);
|
||||||
}
|
}
|
||||||
else if (counter == initFade + inc * 3)
|
else if (counter == initFade + inc * 3)
|
||||||
{
|
{
|
||||||
texture->setColor(color[3].r, color[3].g, color[3].b);
|
texture->setColor(color.at(3).r, color.at(3).g, color.at(3).b);
|
||||||
texture2->setColor(color[3].r, color[3].g, color[3].b);
|
texture2->setColor(color.at(3).r, color.at(3).g, color.at(3).b);
|
||||||
}
|
}
|
||||||
else if (counter == initFade + inc * 4)
|
else if (counter == initFade + inc * 4)
|
||||||
{
|
{
|
||||||
texture->setColor(color[2].r, color[2].g, color[2].b);
|
texture->setColor(color.at(2).r, color.at(2).g, color.at(2).b);
|
||||||
texture2->setColor(color[2].r, color[2].g, color[2].b);
|
texture2->setColor(color.at(2).r, color.at(2).g, color.at(2).b);
|
||||||
}
|
}
|
||||||
else if (counter == initFade + inc * 5)
|
else if (counter == initFade + inc * 5)
|
||||||
{
|
{
|
||||||
texture->setColor(color[1].r, color[1].g, color[1].b);
|
texture->setColor(color.at(1).r, color.at(1).g, color.at(1).b);
|
||||||
texture2->setColor(color[1].r, color[1].g, color[1].b);
|
texture2->setColor(color.at(1).r, color.at(1).g, color.at(1).b);
|
||||||
}
|
}
|
||||||
else if (counter == initFade + inc * 6)
|
else if (counter == initFade + inc * 6)
|
||||||
{
|
{
|
||||||
texture->setColor(color[0].r, color[0].g, color[0].b);
|
texture->setColor(color.at(0).r, color.at(0).g, color.at(0).b);
|
||||||
texture2->setColor(color[0].r, color[0].g, color[0].b);
|
texture2->setColor(color.at(0).r, color.at(0).g, color.at(0).b);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ private:
|
|||||||
SDL_Event *eventHandler; // Manejador de eventos
|
SDL_Event *eventHandler; // Manejador de eventos
|
||||||
std::vector<Sprite *> sprite; // Vector con los sprites de cada linea que forman el bitmap JAILGAMES
|
std::vector<Sprite *> sprite; // Vector con los sprites de cada linea que forman el bitmap JAILGAMES
|
||||||
Sprite *sprite2; // Sprite para manejar la textura2
|
Sprite *sprite2; // Sprite para manejar la textura2
|
||||||
|
options_t *options; // Puntero a las opciones del juego
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
std::vector<color_t> color; // Vector con los colores para el fade
|
std::vector<color_t> color; // Vector con los colores para el fade
|
||||||
@@ -52,7 +53,7 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
Logo(SDL_Renderer *renderer, Screen *screen, Asset *asset, int subsection);
|
Logo(SDL_Renderer *renderer, Screen *screen, Asset *asset, options_t *options, int subsection);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~Logo();
|
~Logo();
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Player::Player(player_t ini, std::string tileset, std::string animation, SDL_Renderer *renderer, Asset *asset, Input *input, Room *room, Debug *debug)
|
Player::Player(player_t ini, std::string tileset, std::string animation, SDL_Renderer *renderer, Asset *asset, options_t *options, Input *input, Room *room, Debug *debug)
|
||||||
{
|
{
|
||||||
// Obten punteros a objetos
|
// Obten punteros a objetos
|
||||||
this->asset = asset;
|
this->asset = asset;
|
||||||
@@ -11,13 +11,14 @@ Player::Player(player_t ini, std::string tileset, std::string animation, SDL_Ren
|
|||||||
this->input = input;
|
this->input = input;
|
||||||
this->room = room;
|
this->room = room;
|
||||||
this->debug = debug;
|
this->debug = debug;
|
||||||
|
this->options = options;
|
||||||
|
|
||||||
// Crea objetos
|
// Crea objetos
|
||||||
texture = new Texture(renderer, asset->get(tileset));
|
texture = new Texture(renderer, asset->get(tileset));
|
||||||
sprite = new AnimatedSprite(texture, renderer, animation);
|
sprite = new AnimatedSprite(texture, renderer, animation);
|
||||||
|
|
||||||
// Inicializa variables
|
// Inicializa variables
|
||||||
color = stringToColor("white");
|
color = stringToColor(options->palette, "white");
|
||||||
onBorder = false;
|
onBorder = false;
|
||||||
border = BORDER_TOP;
|
border = BORDER_TOP;
|
||||||
invincible = false;
|
invincible = false;
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ public:
|
|||||||
Texture *texture; // Textura con los graficos del enemigo
|
Texture *texture; // Textura con los graficos del enemigo
|
||||||
AnimatedSprite *sprite; // Sprite del enemigo
|
AnimatedSprite *sprite; // Sprite del enemigo
|
||||||
Debug *debug; // Objeto para gestionar la información de debug
|
Debug *debug; // Objeto para gestionar la información de debug
|
||||||
|
options_t *options; // Puntero a las opciones del juego
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
float x; // Posición del jugador en el eje X
|
float x; // Posición del jugador en el eje X
|
||||||
@@ -127,7 +128,7 @@ public:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
Player(player_t ini, std::string tileset, std::string animation, SDL_Renderer *renderer, Asset *asset, Input *input, Room *room, Debug *debug);
|
Player(player_t ini, std::string tileset, std::string animation, SDL_Renderer *renderer, Asset *asset, options_t *options, Input *input, Room *room, Debug *debug);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~Player();
|
~Player();
|
||||||
|
|||||||
@@ -4,18 +4,8 @@
|
|||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Room::Room(std::string file, SDL_Renderer *renderer, Screen *screen, Asset *asset, ItemTracker *itemTracker, int *items, Debug *debug)
|
Room::Room(std::string file, SDL_Renderer *renderer, Screen *screen, Asset *asset, options_t *options, ItemTracker *itemTracker, int *items, Debug *debug)
|
||||||
{
|
{
|
||||||
// Inicializa variables
|
|
||||||
tileSize = 8;
|
|
||||||
mapWidth = 32;
|
|
||||||
mapHeight = 16;
|
|
||||||
paused = false;
|
|
||||||
itemColor1 = stringToColor("magenta");
|
|
||||||
itemColor2 = stringToColor("yellow");
|
|
||||||
autoSurfaceDirection = 1;
|
|
||||||
counter = 0;
|
|
||||||
|
|
||||||
// Copia los punteros a objetos
|
// Copia los punteros a objetos
|
||||||
this->renderer = renderer;
|
this->renderer = renderer;
|
||||||
this->asset = asset;
|
this->asset = asset;
|
||||||
@@ -23,6 +13,17 @@ Room::Room(std::string file, SDL_Renderer *renderer, Screen *screen, Asset *asse
|
|||||||
this->itemTracker = itemTracker;
|
this->itemTracker = itemTracker;
|
||||||
this->itemsPicked = items;
|
this->itemsPicked = items;
|
||||||
this->debug = debug;
|
this->debug = debug;
|
||||||
|
this->options = options;
|
||||||
|
|
||||||
|
// Inicializa variables
|
||||||
|
tileSize = 8;
|
||||||
|
mapWidth = 32;
|
||||||
|
mapHeight = 16;
|
||||||
|
paused = false;
|
||||||
|
itemColor1 = stringToColor(options->palette, "magenta");
|
||||||
|
itemColor2 = stringToColor(options->palette, "yellow");
|
||||||
|
autoSurfaceDirection = 1;
|
||||||
|
counter = 0;
|
||||||
|
|
||||||
// Crea los objetos
|
// Crea los objetos
|
||||||
loadMapFile(file);
|
loadMapFile(file);
|
||||||
@@ -297,27 +298,35 @@ bool Room::setVars(std::string var, std::string value)
|
|||||||
|
|
||||||
else if (var == "bgColor")
|
else if (var == "bgColor")
|
||||||
{
|
{
|
||||||
bgColor = stringToColor(value);
|
bgColor = stringToColor(options->palette, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (var == "border")
|
else if (var == "border")
|
||||||
{
|
{
|
||||||
borderColor = stringToColor(value);
|
borderColor = stringToColor(options->palette, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (var == "itemColor1")
|
else if (var == "itemColor1")
|
||||||
{
|
{
|
||||||
itemColor1 = stringToColor(value);
|
itemColor1 = stringToColor(options->palette, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (var == "itemColor2")
|
else if (var == "itemColor2")
|
||||||
{
|
{
|
||||||
itemColor2 = stringToColor(value);
|
itemColor2 = stringToColor(options->palette, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (var == "tileset")
|
else if (var == "tileset")
|
||||||
{
|
{
|
||||||
tileset = value;
|
tileset = value;
|
||||||
|
if (options->palette == p_zxspectrum)
|
||||||
|
{
|
||||||
|
tileset = "standard.png";
|
||||||
|
}
|
||||||
|
else if (options->palette == p_zxarne)
|
||||||
|
{
|
||||||
|
tileset = "standard_zxarne.png";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (var == "roomUp")
|
else if (var == "roomUp")
|
||||||
@@ -437,7 +446,7 @@ bool Room::setEnemy(enemy_t *enemy, std::string var, std::string value)
|
|||||||
|
|
||||||
else if (var == "color")
|
else if (var == "color")
|
||||||
{
|
{
|
||||||
enemy->color = stringToColor(value);
|
enemy->color = stringToColor(options->palette, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (var == "[/enemy]")
|
else if (var == "[/enemy]")
|
||||||
@@ -810,7 +819,15 @@ bool Room::itemCollision(SDL_Rect &rect)
|
|||||||
// Recarga la textura
|
// Recarga la textura
|
||||||
void Room::reLoadTexture()
|
void Room::reLoadTexture()
|
||||||
{
|
{
|
||||||
texture->reLoad();
|
if (options->palette == p_zxspectrum)
|
||||||
|
{
|
||||||
|
texture->loadFromFile(asset->get("standard.png"), renderer);
|
||||||
|
}
|
||||||
|
else if (options->palette == p_zxarne)
|
||||||
|
{
|
||||||
|
texture->loadFromFile(asset->get("standard_zxarne.png"), renderer);
|
||||||
|
}
|
||||||
|
// texture->reLoad();
|
||||||
fillMapTexture();
|
fillMapTexture();
|
||||||
for (auto enemy : enemies)
|
for (auto enemy : enemies)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ private:
|
|||||||
SDL_Texture *mapTexture; // Textura para dibujar el mapa de la habitación
|
SDL_Texture *mapTexture; // Textura para dibujar el mapa de la habitación
|
||||||
int *itemsPicked; // Puntero a la cantidad de items recogidos que lleva el juego
|
int *itemsPicked; // Puntero a la cantidad de items recogidos que lleva el juego
|
||||||
Debug *debug; // Objeto para gestionar la información de debug
|
Debug *debug; // Objeto para gestionar la información de debug
|
||||||
|
options_t *options; // Puntero a las opciones del juego
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
std::string name; // Nombre de la habitación
|
std::string name; // Nombre de la habitación
|
||||||
@@ -132,7 +133,7 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
Room(std::string file, SDL_Renderer *renderer, Screen *screen, Asset *asset, ItemTracker *item_tracker, int *items, Debug *debug);
|
Room(std::string file, SDL_Renderer *renderer, Screen *screen, Asset *asset, options_t *options, ItemTracker *item_tracker, int *items, Debug *debug);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~Room();
|
~Room();
|
||||||
|
|||||||
@@ -3,12 +3,13 @@
|
|||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
ScoreBoard::ScoreBoard(SDL_Renderer *renderer, Asset *asset, board_t *board)
|
ScoreBoard::ScoreBoard(SDL_Renderer *renderer, Asset *asset, options_t *options, board_t *board)
|
||||||
{
|
{
|
||||||
// Obten punteros a objetos
|
// Obten punteros a objetos
|
||||||
this->asset = asset;
|
this->asset = asset;
|
||||||
this->renderer = renderer;
|
this->renderer = renderer;
|
||||||
this->board = board;
|
this->board = board;
|
||||||
|
this->options = options;
|
||||||
|
|
||||||
// Reserva memoria para los objetos
|
// Reserva memoria para los objetos
|
||||||
playerTexture = new Texture(renderer, asset->get("player.png"));
|
playerTexture = new Texture(renderer, asset->get("player.png"));
|
||||||
@@ -28,7 +29,7 @@ ScoreBoard::ScoreBoard(SDL_Renderer *renderer, Asset *asset, board_t *board)
|
|||||||
const std::vector<std::string> vColors = {"blue", "magenta", "green", "cyan", "yellow", "white", "bright_blue", "bright_magenta", "bright_green", "bright_cyan", "bright_yellow", "bright_white"};
|
const std::vector<std::string> vColors = {"blue", "magenta", "green", "cyan", "yellow", "white", "bright_blue", "bright_magenta", "bright_green", "bright_cyan", "bright_yellow", "bright_white"};
|
||||||
for (auto v : vColors)
|
for (auto v : vColors)
|
||||||
{
|
{
|
||||||
color.push_back(stringToColor(v));
|
color.push_back(stringToColor(options->palette, v));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,7 +54,6 @@ void ScoreBoard::render()
|
|||||||
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
|
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
|
||||||
SDL_RenderFillRect(renderer, &rect);
|
SDL_RenderFillRect(renderer, &rect);
|
||||||
|
|
||||||
|
|
||||||
// Dibuja las vidas
|
// Dibuja las vidas
|
||||||
const int desp = (counter / 40) % 8;
|
const int desp = (counter / 40) % 8;
|
||||||
const int frame = desp % 4;
|
const int frame = desp % 4;
|
||||||
@@ -80,13 +80,13 @@ void ScoreBoard::render()
|
|||||||
const std::string timeTxt = std::to_string((clock.minutes % 60) / 10) + std::to_string(clock.minutes % 10) + clock.separator + std::to_string((clock.seconds % 60) / 10) + std::to_string(clock.seconds % 10);
|
const std::string timeTxt = std::to_string((clock.minutes % 60) / 10) + std::to_string(clock.minutes % 10) + clock.separator + std::to_string((clock.seconds % 60) / 10) + std::to_string(clock.seconds % 10);
|
||||||
const std::string itemsTxt = std::to_string(board->items / 100) + std::to_string((board->items % 100) / 10) + std::to_string(board->items % 10);
|
const std::string itemsTxt = std::to_string(board->items / 100) + std::to_string((board->items % 100) / 10) + std::to_string(board->items % 10);
|
||||||
this->text->writeColored(BLOCK, line1, "Items collected ", board->color);
|
this->text->writeColored(BLOCK, line1, "Items collected ", board->color);
|
||||||
this->text->writeColored(17 * BLOCK, line1, itemsTxt, stringToColor("white"));
|
this->text->writeColored(17 * BLOCK, line1, itemsTxt, stringToColor(options->palette, "white"));
|
||||||
this->text->writeColored(20 * BLOCK, line1, " Time ", board->color);
|
this->text->writeColored(20 * BLOCK, line1, " Time ", board->color);
|
||||||
this->text->writeColored(26 * BLOCK, line1, timeTxt, stringToColor("white"));
|
this->text->writeColored(26 * BLOCK, line1, timeTxt, stringToColor(options->palette, "white"));
|
||||||
|
|
||||||
const std::string roomsTxt = std::to_string(board->rooms / 100) + std::to_string((board->rooms % 100) / 10) + std::to_string(board->rooms % 10);
|
const std::string roomsTxt = std::to_string(board->rooms / 100) + std::to_string((board->rooms % 100) / 10) + std::to_string(board->rooms % 10);
|
||||||
this->text->writeColored(22 * BLOCK, line2, "Rooms", stringToColor("white"));
|
this->text->writeColored(22 * BLOCK, line2, "Rooms", stringToColor(options->palette, "white"));
|
||||||
this->text->writeColored(28 * BLOCK, line2, roomsTxt, stringToColor("white"));
|
this->text->writeColored(28 * BLOCK, line2, roomsTxt, stringToColor(options->palette, "white"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actualiza las variables del objeto
|
// Actualiza las variables del objeto
|
||||||
@@ -121,6 +121,14 @@ void ScoreBoard::reLoadTexture()
|
|||||||
playerTexture->reLoad();
|
playerTexture->reLoad();
|
||||||
itemTexture->reLoad();
|
itemTexture->reLoad();
|
||||||
text->reLoadTexture();
|
text->reLoadTexture();
|
||||||
|
|
||||||
|
// Reinicia el vector de colores
|
||||||
|
const std::vector<std::string> vColors = {"blue", "magenta", "green", "cyan", "yellow", "white", "bright_blue", "bright_magenta", "bright_green", "bright_cyan", "bright_yellow", "bright_white"};
|
||||||
|
color.clear();
|
||||||
|
for (auto v : vColors)
|
||||||
|
{
|
||||||
|
color.push_back(stringToColor(options->palette, v));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pone el marcador en modo pausa
|
// Pone el marcador en modo pausa
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ private:
|
|||||||
Text *text; // Objeto para escribir texto
|
Text *text; // Objeto para escribir texto
|
||||||
Texture *itemTexture; // Textura con los graficos para las vidas
|
Texture *itemTexture; // Textura con los graficos para las vidas
|
||||||
board_t *board; // Contiene las variables a mostrar en el marcador
|
board_t *board; // Contiene las variables a mostrar en el marcador
|
||||||
|
options_t *options; // Puntero a las opciones del juego
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
std::vector<color_t> color; // Vector con los colores del objeto
|
std::vector<color_t> color; // Vector con los colores del objeto
|
||||||
@@ -55,7 +56,7 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
ScoreBoard(SDL_Renderer *renderer, Asset *asset, board_t *board);
|
ScoreBoard(SDL_Renderer *renderer, Asset *asset, options_t *options, board_t *board);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~ScoreBoard();
|
~ScoreBoard();
|
||||||
|
|||||||
@@ -1,16 +1,24 @@
|
|||||||
#include "title.h"
|
#include "title.h"
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Title::Title(SDL_Renderer *renderer, Screen *screen, Asset *asset)
|
Title::Title(SDL_Renderer *renderer, Screen *screen, Asset *asset, options_t *options)
|
||||||
{
|
{
|
||||||
// Copia la dirección de los objetos
|
// Copia la dirección de los objetos
|
||||||
this->renderer = renderer;
|
this->renderer = renderer;
|
||||||
this->screen = screen;
|
this->screen = screen;
|
||||||
this->asset = asset;
|
this->asset = asset;
|
||||||
|
this->options = options;
|
||||||
|
|
||||||
// Reserva memoria para los punteros
|
// Reserva memoria para los punteros
|
||||||
eventHandler = new SDL_Event();
|
eventHandler = new SDL_Event();
|
||||||
|
if (options->palette == p_zxspectrum)
|
||||||
|
{
|
||||||
texture = new Texture(renderer, asset->get("loading_screen_color.png"));
|
texture = new Texture(renderer, asset->get("loading_screen_color.png"));
|
||||||
|
}
|
||||||
|
else if (options->palette == p_zxarne)
|
||||||
|
{
|
||||||
|
texture = new Texture(renderer, asset->get("loading_screen_color_zxarne.png"));
|
||||||
|
}
|
||||||
sprite = new Sprite(0, 0, texture->getWidth(), texture->getHeight(), texture, renderer);
|
sprite = new Sprite(0, 0, texture->getWidth(), texture->getHeight(), texture, renderer);
|
||||||
text = new Text(asset->get("smb2.png"), asset->get("smb2.txt"), renderer);
|
text = new Text(asset->get("smb2.png"), asset->get("smb2.txt"), renderer);
|
||||||
|
|
||||||
@@ -21,7 +29,7 @@ Title::Title(SDL_Renderer *renderer, Screen *screen, Asset *asset)
|
|||||||
ticks = 0;
|
ticks = 0;
|
||||||
ticksSpeed = 15;
|
ticksSpeed = 15;
|
||||||
longText = "HEY JAILERS!! IT'S 2022 AND WE'RE STILL ROCKING LIKE IT'S 1998!!! HAVE YOU HEARD IT? JAILGAMES ARE BACK!! YEEESSS BACK!! MORE THAN 10 TITLES ON JAILDOC'S KITCHEN!! THATS A LOOOOOOT OF JAILGAMES, BUT WHICH ONE WILL STRIKE FIRST? THERE IS ALSO A NEW DEVICE TO COME P.A.C.O. THAT WILL BLOW YOUR MIND WITH JAILGAMES ON THE GO. BUT WAIT! WHAT'S THAT BEAUTY I'M SEEING RIGHT OVER THERE?? OOOH THAT TINY MINIASCII IS PURE LOVE!! I WANT TO LICK EVERY BYTE OF IT!! OH SHIT! AND DON'T FORGET TO BRING BACK THOSE OLD AND FAT MS-DOS JAILGAMES TO GITHUB TO KEEP THEM ALIVE!! WHAT WILL BE THE NEXT JAILDOC RELEASE? WHAT WILL BE THE NEXT PROJECT TO COME ALIVE?? OH BABY WE DON'T KNOW BUT HERE YOU CAN FIND THE ANSWER, YOU JUST HAVE TO COMPLETE JAILDOCTOR'S DILEMMA ... COULD YOU?";
|
longText = "HEY JAILERS!! IT'S 2022 AND WE'RE STILL ROCKING LIKE IT'S 1998!!! HAVE YOU HEARD IT? JAILGAMES ARE BACK!! YEEESSS BACK!! MORE THAN 10 TITLES ON JAILDOC'S KITCHEN!! THATS A LOOOOOOT OF JAILGAMES, BUT WHICH ONE WILL STRIKE FIRST? THERE IS ALSO A NEW DEVICE TO COME P.A.C.O. THAT WILL BLOW YOUR MIND WITH JAILGAMES ON THE GO. BUT WAIT! WHAT'S THAT BEAUTY I'M SEEING RIGHT OVER THERE?? OOOH THAT TINY MINIASCII IS PURE LOVE!! I WANT TO LICK EVERY BYTE OF IT!! OH SHIT! AND DON'T FORGET TO BRING BACK THOSE OLD AND FAT MS-DOS JAILGAMES TO GITHUB TO KEEP THEM ALIVE!! WHAT WILL BE THE NEXT JAILDOC RELEASE? WHAT WILL BE THE NEXT PROJECT TO COME ALIVE?? OH BABY WE DON'T KNOW BUT HERE YOU CAN FIND THE ANSWER, YOU JUST HAVE TO COMPLETE JAILDOCTOR'S DILEMMA ... COULD YOU?";
|
||||||
//longText = "HEY JAILERS!! IT'S 2022 AND WE'RE STILL ROCKING LIKE IT'S 1998!!!";
|
// longText = "HEY JAILERS!! IT'S 2022 AND WE'RE STILL ROCKING LIKE IT'S 1998!!!";
|
||||||
for (int i = 0; i < (int)longText.length(); ++i)
|
for (int i = 0; i < (int)longText.length(); ++i)
|
||||||
{
|
{
|
||||||
letter_t l;
|
letter_t l;
|
||||||
@@ -33,7 +41,7 @@ Title::Title(SDL_Renderer *renderer, Screen *screen, Asset *asset)
|
|||||||
letters[0].enabled = true;
|
letters[0].enabled = true;
|
||||||
|
|
||||||
// Cambia el color del borde
|
// Cambia el color del borde
|
||||||
screen->setBorderColor(stringToColor("bright_blue"));
|
screen->setBorderColor(stringToColor(options->palette, "bright_blue"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
@@ -134,8 +142,7 @@ void Title::renderMarquee()
|
|||||||
{
|
{
|
||||||
if (l.enabled)
|
if (l.enabled)
|
||||||
{
|
{
|
||||||
// text->writeColored(l.x, 176, l.letter, {0, 0, 0});
|
text->writeColored(l.x, 184, l.letter, stringToColor(options->palette, "white"));
|
||||||
text->write(l.x, 184, l.letter);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -188,11 +195,12 @@ void Title::render()
|
|||||||
// text->writeCentered(256 / 2, 192 / 5 * 4, "PRESS ENTER TO PLAY");
|
// text->writeCentered(256 / 2, 192 / 5 * 4, "PRESS ENTER TO PLAY");
|
||||||
//}
|
//}
|
||||||
|
|
||||||
|
// Dibuja el texto de PRESS ENTER TO PLAY
|
||||||
if (counter % 80 < 60)
|
if (counter % 80 < 60)
|
||||||
{
|
{
|
||||||
const color_t textColor = stringToColor("white");
|
const color_t textColor = stringToColor(options->palette, "white");
|
||||||
const color_t strokeColor = stringToColor("bright_blue");
|
const color_t strokeColor = stringToColor(options->palette, "bright_blue");
|
||||||
text->writeDX(TXT_CENTER | TXT_COLOR| TXT_STROKE, 256 / 2, 192 / 5 * 4, "PRESS ENTER TO PLAY", 1, textColor, 1, strokeColor);
|
text->writeDX(TXT_CENTER | TXT_COLOR | TXT_STROKE, 256 / 2, 192 / 5 * 4, "PRESS ENTER TO PLAY", 1, textColor, 1, strokeColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dibuja la marquesina
|
// Dibuja la marquesina
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ private:
|
|||||||
Texture *texture; // Textura con los graficos
|
Texture *texture; // Textura con los graficos
|
||||||
Sprite *sprite; // Sprite para manejar la textura
|
Sprite *sprite; // Sprite para manejar la textura
|
||||||
Text *text; // Objeto para escribir texto en pantalla
|
Text *text; // Objeto para escribir texto en pantalla
|
||||||
|
options_t *options; // Puntero a las opciones del juego
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
int counter; // Contador
|
int counter; // Contador
|
||||||
@@ -57,7 +58,7 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
Title(SDL_Renderer *renderer, Screen *screen, Asset *asset);
|
Title(SDL_Renderer *renderer, Screen *screen, Asset *asset, options_t *options);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~Title();
|
~Title();
|
||||||
|
|||||||