PETA QUE NI EL PEPE KARTS
This commit is contained in:
14
Makefile
14
Makefile
@@ -52,10 +52,10 @@ windows_release:
|
|||||||
powershell if (Test-Path "$(releaseFolder)") {Remove-Item "$(releaseFolder)" -Recurse -Force}
|
powershell if (Test-Path "$(releaseFolder)") {Remove-Item "$(releaseFolder)" -Recurse -Force}
|
||||||
|
|
||||||
macos:
|
macos:
|
||||||
clang++ $(source) -std=$(cpp_standard) -Wall -Os -lSDL2 -ffunction-sections -fdata-sections -o "$(executable)"
|
clang++ $(source) -std=$(cpp_standard) -Wall -Os -lSDL2 -framework OpenGL -Wno-deprecated -ffunction-sections -fdata-sections -o "$(executable)"
|
||||||
|
|
||||||
macos_debug:
|
macos_debug:
|
||||||
clang++ $(source) -D DEBUG -std=$(cpp_standard) -Wall -Os -lSDL2 -ffunction-sections -fdata-sections -o "$(executable)_debug"
|
clang++ $(source) -D DEBUG -std=$(cpp_standard) -Wall -Os -lSDL2 -framework OpenGL -Wno-deprecated -ffunction-sections -fdata-sections -o "$(executable)_debug"
|
||||||
|
|
||||||
macos_release:
|
macos_release:
|
||||||
# Remove data and possible data from previous builds
|
# Remove data and possible data from previous builds
|
||||||
@@ -90,7 +90,7 @@ macos_release:
|
|||||||
ln -s /Applications "$(releaseFolder)"/Applications
|
ln -s /Applications "$(releaseFolder)"/Applications
|
||||||
|
|
||||||
# Build INTEL
|
# Build INTEL
|
||||||
clang++ $(source) -D MACOS_BUNDLE -std=$(cpp_standard) -Wall -Os -framework SDL2 -F ./Frameworks -ffunction-sections -fdata-sections -o "$(releaseFolder)/$(appName).app/Contents/MacOS/$(executable)" -rpath @executable_path/../Frameworks/ -target x86_64-apple-macos10.12
|
clang++ $(source) -D MACOS_BUNDLE -std=$(cpp_standard) -Wall -Os -framework SDL2 -F ./Frameworks -framework OpenGL -Wno-deprecated -ffunction-sections -fdata-sections -o "$(releaseFolder)/$(appName).app/Contents/MacOS/$(executable)" -rpath @executable_path/../Frameworks/ -target x86_64-apple-macos10.12
|
||||||
|
|
||||||
# Build INTEL DMG
|
# Build INTEL DMG
|
||||||
hdiutil create tmp.dmg -ov -volname "$(appName)" -fs HFS+ -srcfolder "$(releaseFolder)"
|
hdiutil create tmp.dmg -ov -volname "$(appName)" -fs HFS+ -srcfolder "$(releaseFolder)"
|
||||||
@@ -98,7 +98,7 @@ macos_release:
|
|||||||
rm -f tmp.dmg
|
rm -f tmp.dmg
|
||||||
|
|
||||||
# Build APPLE SILICON
|
# Build APPLE SILICON
|
||||||
clang++ $(source) -D MACOS_BUNDLE -std=$(cpp_standard) -Wall -Os -framework SDL2 -F ./Frameworks -ffunction-sections -fdata-sections -o "$(releaseFolder)/$(appName).app/Contents/MacOS/$(executable)" -rpath @executable_path/../Frameworks/ -target arm64-apple-macos11
|
clang++ $(source) -D MACOS_BUNDLE -std=$(cpp_standard) -Wall -Os -framework SDL2 -F ./Frameworks -framework OpenGL -Wno-deprecated -ffunction-sections -fdata-sections -o "$(releaseFolder)/$(appName).app/Contents/MacOS/$(executable)" -rpath @executable_path/../Frameworks/ -target arm64-apple-macos11
|
||||||
|
|
||||||
# Build APPLE SILICON DMG
|
# Build APPLE SILICON DMG
|
||||||
hdiutil create tmp.dmg -ov -volname "$(appName)" -fs HFS+ -srcfolder "$(releaseFolder)"
|
hdiutil create tmp.dmg -ov -volname "$(appName)" -fs HFS+ -srcfolder "$(releaseFolder)"
|
||||||
@@ -110,11 +110,11 @@ macos_release:
|
|||||||
rm -rdf "$(releaseFolder)"
|
rm -rdf "$(releaseFolder)"
|
||||||
|
|
||||||
linux:
|
linux:
|
||||||
g++ $(source) -std=$(cpp_standard) -Wall -Os -lSDL2 -ffunction-sections -fdata-sections -Wl,--gc-sections -o "$(executable)"
|
g++ $(source) -std=$(cpp_standard) -Wall -Os -lSDL2 -lGL -ffunction-sections -fdata-sections -Wl,--gc-sections -o "$(executable)"
|
||||||
strip -s -R .comment -R .gnu.version "$(executable)" --strip-unneeded
|
strip -s -R .comment -R .gnu.version "$(executable)" --strip-unneeded
|
||||||
|
|
||||||
linux_debug:
|
linux_debug:
|
||||||
g++ $(source) -D DEBUG -std=$(cpp_standard) -Wall -Os -lSDL2 -ffunction-sections -fdata-sections -Wl,--gc-sections -o "$(executable)_debug"
|
g++ $(source) -D DEBUG -std=$(cpp_standard) -Wall -Os -lSDL2 -lGL -ffunction-sections -fdata-sections -Wl,--gc-sections -o "$(executable)_debug"
|
||||||
strip -s -R .comment -R .gnu.version "$(executable)_debug" --strip-unneeded
|
strip -s -R .comment -R .gnu.version "$(executable)_debug" --strip-unneeded
|
||||||
|
|
||||||
linux_release:
|
linux_release:
|
||||||
@@ -134,7 +134,7 @@ linux_release:
|
|||||||
rm -f "$(releaseFolder)/data/room/standard.tsx"
|
rm -f "$(releaseFolder)/data/room/standard.tsx"
|
||||||
|
|
||||||
# Build
|
# Build
|
||||||
g++ $(source) -std=$(cpp_standard) -Wall -Os -lSDL2 -ffunction-sections -fdata-sections -Wl,--gc-sections -o "$(releaseFolder)/$(executable)"
|
g++ $(source) -std=$(cpp_standard) -Wall -Os -lSDL2 -lGL -ffunction-sections -fdata-sections -Wl,--gc-sections -o "$(releaseFolder)/$(executable)"
|
||||||
strip -s -R .comment -R .gnu.version "$(releaseFolder)/$(executable)" --strip-unneeded
|
strip -s -R .comment -R .gnu.version "$(releaseFolder)/$(executable)" --strip-unneeded
|
||||||
|
|
||||||
# Pack files
|
# Pack files
|
||||||
|
|||||||
@@ -28,8 +28,8 @@ Credits::Credits(Resource *resource, options_t *options, section_t *section)
|
|||||||
{
|
{
|
||||||
// Reserva memoria para los punteros
|
// Reserva memoria para los punteros
|
||||||
event_handler_ = new SDL_Event();
|
event_handler_ = new SDL_Event();
|
||||||
text_ = new Text(resource->getOffset("smb2.txt"), resource->getTexture("smb2.png"), renderer_);
|
text_ = new Text(resource_->getOffset("smb2.txt"), resource_->getTexture("smb2.png"), renderer_);
|
||||||
sprite_ = new AnimatedSprite(renderer_, resource->getAnimation("shine.ani"));
|
sprite_ = new AnimatedSprite(renderer_, resource_->getAnimation("shine.ani"));
|
||||||
|
|
||||||
// Inicializa variables
|
// Inicializa variables
|
||||||
section->name = SECTION_CREDITS;
|
section->name = SECTION_CREDITS;
|
||||||
|
|||||||
@@ -63,4 +63,4 @@ public:
|
|||||||
|
|
||||||
// Cambia el valor de la variable
|
// Cambia el valor de la variable
|
||||||
void switchEnabled();
|
void switchEnabled();
|
||||||
};
|
};
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
class Debug;
|
class Debug;
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Demo::Demo(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, Input *input, options_t *options, section_t *section, Debug *debug)
|
Demo::Demo(Resource *resource, options_t *options, section_t *section, Debug *debug)
|
||||||
{
|
{
|
||||||
// Inicia algunas variables
|
// Inicia algunas variables
|
||||||
board.iniClock = SDL_GetTicks();
|
board.iniClock = SDL_GetTicks();
|
||||||
@@ -31,11 +31,11 @@ Demo::Demo(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *as
|
|||||||
currentRoom = rooms[roomIndex];
|
currentRoom = rooms[roomIndex];
|
||||||
|
|
||||||
// Copia los punteros
|
// Copia los punteros
|
||||||
this->renderer = renderer;
|
|
||||||
this->screen = screen;
|
|
||||||
this->resource = resource;
|
this->resource = resource;
|
||||||
this->asset = asset;
|
this->screen = Screen::get();
|
||||||
this->input = input;
|
this->renderer = Screen::get()->getRenderer();
|
||||||
|
this->asset = Asset::get();
|
||||||
|
this->input = Input::get();
|
||||||
this->options = options;
|
this->options = options;
|
||||||
this->section = section;
|
this->section = section;
|
||||||
this->debug = debug;
|
this->debug = debug;
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
Demo(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, Input *input, options_t *options, section_t *section, Debug *debug);
|
Demo(Resource *resource, options_t *options, section_t *section, Debug *debug);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~Demo();
|
~Demo();
|
||||||
|
|||||||
@@ -36,6 +36,7 @@
|
|||||||
#include "resource.h" // Para Resource
|
#include "resource.h" // Para Resource
|
||||||
#include "screen.h" // Para Screen, FILTER_NEAREST, FILTER...
|
#include "screen.h" // Para Screen, FILTER_NEAREST, FILTER...
|
||||||
#include "utils.h" // Para options_t, section_t, op_notif...
|
#include "utils.h" // Para options_t, section_t, op_notif...
|
||||||
|
#include "notifier.h"
|
||||||
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
@@ -53,15 +54,16 @@ Director::Director(int argc, const char *argv[])
|
|||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
section->name = SECTION_TITLE;
|
section->name = SECTION_TITLE;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Asset::init(argv[0]); // Crea el objeto que controla los ficheros de recursos
|
|
||||||
|
|
||||||
// Crea e inicializa las opciones del programa
|
// Crea e inicializa las opciones del programa
|
||||||
initOptions();
|
initOptions();
|
||||||
|
|
||||||
// Comprueba los parametros del programa
|
// Comprueba los parametros del programa
|
||||||
checkProgramArguments(argc, argv);
|
checkProgramArguments(argc, argv);
|
||||||
|
|
||||||
|
// Crea el objeto que controla los ficheros de recursos
|
||||||
|
Asset::init(executable_path_);
|
||||||
|
Asset::get()->setVerbose(options->console);
|
||||||
|
|
||||||
// Crea la carpeta del sistema donde guardar datos
|
// Crea la carpeta del sistema donde guardar datos
|
||||||
createSystemFolder("jailgames");
|
createSystemFolder("jailgames");
|
||||||
#ifndef DEBUG
|
#ifndef DEBUG
|
||||||
@@ -70,9 +72,6 @@ Director::Director(int argc, const char *argv[])
|
|||||||
createSystemFolder("jailgames/jaildoctors_dilemma_debug");
|
createSystemFolder("jailgames/jaildoctors_dilemma_debug");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Crea el objeto que controla los ficheros de recursos
|
|
||||||
Asset::get()->setVerbose(options->console);
|
|
||||||
|
|
||||||
// Si falta algún fichero no inicia el programa
|
// Si falta algún fichero no inicia el programa
|
||||||
if (!setFileList())
|
if (!setFileList())
|
||||||
{
|
{
|
||||||
@@ -91,6 +90,7 @@ Director::Director(int argc, const char *argv[])
|
|||||||
// Crea los objetos
|
// Crea los objetos
|
||||||
Screen::init(window_, renderer_);
|
Screen::init(window_, renderer_);
|
||||||
Screen::get()->setBorderColor(borderColor);
|
Screen::get()->setBorderColor(borderColor);
|
||||||
|
Notifier::init(Asset::get()->get("notify.png"), Asset::get()->get("smb2.png"), Asset::get()->get("smb2.txt"), Asset::get()->get("notify.wav"), options);
|
||||||
resource_ = new Resource(options);
|
resource_ = new Resource(options);
|
||||||
Input::init(Asset::get()->get("gamecontrollerdb.txt"));
|
Input::init(Asset::get()->get("gamecontrollerdb.txt"));
|
||||||
initInput();
|
initInput();
|
||||||
@@ -104,6 +104,10 @@ Director::~Director()
|
|||||||
saveConfig();
|
saveConfig();
|
||||||
|
|
||||||
// Libera la memoria
|
// Libera la memoria
|
||||||
|
Asset::destroy();
|
||||||
|
Input::destroy();
|
||||||
|
Screen::destroy();
|
||||||
|
Notifier::destroy();
|
||||||
delete section;
|
delete section;
|
||||||
delete options;
|
delete options;
|
||||||
delete debug_;
|
delete debug_;
|
||||||
@@ -416,11 +420,11 @@ void Director::createSystemFolder(const std::string &folder)
|
|||||||
#elif __APPLE__
|
#elif __APPLE__
|
||||||
struct passwd *pw = getpwuid(getuid());
|
struct passwd *pw = getpwuid(getuid());
|
||||||
const char *homedir = pw->pw_dir;
|
const char *homedir = pw->pw_dir;
|
||||||
systemFolder = std::string(homedir) + "/Library/Application Support" + "/" + folder;
|
system_folder_ = std::string(homedir) + "/Library/Application Support" + "/" + folder;
|
||||||
#elif __linux__
|
#elif __linux__
|
||||||
struct passwd *pw = getpwuid(getuid());
|
struct passwd *pw = getpwuid(getuid());
|
||||||
const char *homedir = pw->pw_dir;
|
const char *homedir = pw->pw_dir;
|
||||||
systemFolder = std::string(homedir) + "/.config/" + folder;
|
system_folder_ = std::string(homedir) + "/.config/" + folder;
|
||||||
|
|
||||||
{
|
{
|
||||||
// Intenta crear ".config", per si no existeix
|
// Intenta crear ".config", per si no existeix
|
||||||
@@ -441,7 +445,7 @@ void Director::createSystemFolder(const std::string &folder)
|
|||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
int ret = mkdir(system_folder_.c_str());
|
int ret = mkdir(system_folder_.c_str());
|
||||||
#else
|
#else
|
||||||
int ret = mkdir(systemFolder.c_str(), S_IRWXU);
|
int ret = mkdir(system_folder_.c_str(), S_IRWXU);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (ret == -1)
|
if (ret == -1)
|
||||||
|
|||||||
@@ -18,14 +18,14 @@
|
|||||||
#include "utils.h" // Para color_t, stringToColor, options_t
|
#include "utils.h" // Para color_t, stringToColor, options_t
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Ending::Ending(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, Input *input, options_t *options, section_t *section)
|
Ending::Ending(Resource *resource, options_t *options, section_t *section)
|
||||||
{
|
{
|
||||||
// Copia los punteros
|
// Copia los punteros
|
||||||
this->renderer = renderer;
|
this->screen = Screen::get();
|
||||||
this->screen = screen;
|
this->renderer = Screen::get()->getRenderer();
|
||||||
this->resource = resource;
|
this->resource = resource;
|
||||||
this->asset = asset;
|
this->asset = Asset::get();
|
||||||
this->input = input;
|
this->input = Input::get();
|
||||||
this->options = options;
|
this->options = options;
|
||||||
this->section = section;
|
this->section = section;
|
||||||
|
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
Ending(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, Input *input, options_t *options, section_t *section);
|
Ending(Resource *resource, options_t *options, section_t *section);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~Ending();
|
~Ending();
|
||||||
|
|||||||
@@ -15,14 +15,14 @@
|
|||||||
#include "utils.h" // for color_t, stringToColor, options_t
|
#include "utils.h" // for color_t, stringToColor, options_t
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Ending2::Ending2(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, Input *input, options_t *options, section_t *section)
|
Ending2::Ending2(Resource *resource, options_t *options, section_t *section)
|
||||||
{
|
{
|
||||||
// Copia los punteros
|
// Copia los punteros
|
||||||
this->renderer = renderer;
|
this->screen = Screen::get();
|
||||||
this->screen = screen;
|
this->renderer = Screen::get()->getRenderer();
|
||||||
this->resource = resource;
|
this->resource = resource;
|
||||||
this->asset = asset;
|
this->asset = Asset::get();
|
||||||
this->input = input;
|
this->input = Input::get();
|
||||||
this->options = options;
|
this->options = options;
|
||||||
this->section = section;
|
this->section = section;
|
||||||
|
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
Ending2(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, Input *input, options_t *options, section_t *section);
|
Ending2(Resource *resource, options_t *options, section_t *section);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~Ending2();
|
~Ending2();
|
||||||
|
|||||||
486
source/game.cpp
486
source/game.cpp
@@ -22,52 +22,50 @@
|
|||||||
#include "utils.h" // for options_t, cheat_t, stringToColor
|
#include "utils.h" // for options_t, cheat_t, stringToColor
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Game::Game(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options, Input *input, section_t *section, Debug *debug)
|
Game::Game(Resource *resource, options_t *options, section_t *section, Debug *debug)
|
||||||
|
: screen_(Screen::get()),
|
||||||
|
renderer_(Screen::get()->getRenderer()),
|
||||||
|
asset_(Asset::get()),
|
||||||
|
input_(Input::get()),
|
||||||
|
resource_(resource),
|
||||||
|
debug_(debug),
|
||||||
|
options_(options),
|
||||||
|
section_(section)
|
||||||
{
|
{
|
||||||
// Copia los punteros
|
|
||||||
this->resource = resource;
|
|
||||||
this->renderer = renderer;
|
|
||||||
this->asset = asset;
|
|
||||||
this->screen = screen;
|
|
||||||
this->input = input;
|
|
||||||
this->debug = debug;
|
|
||||||
this->options = options;
|
|
||||||
this->section = section;
|
|
||||||
|
|
||||||
// Inicia algunas variables
|
// Inicia algunas variables
|
||||||
board.iniClock = SDL_GetTicks();
|
board_.iniClock = SDL_GetTicks();
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
currentRoom = "03.room";
|
current_room_ = "03.room";
|
||||||
const int x = 25;
|
const int x = 25;
|
||||||
const int y = 13;
|
const int y = 13;
|
||||||
spawnPoint = {x * 8, y * 8, 0, 0, 0, s_standing, SDL_FLIP_HORIZONTAL};
|
spawn_point_ = {x * 8, y * 8, 0, 0, 0, s_standing, SDL_FLIP_HORIZONTAL};
|
||||||
debug->setEnabled(false);
|
debug->setEnabled(false);
|
||||||
#else
|
#else
|
||||||
currentRoom = "03.room";
|
current_room_ = "03.room";
|
||||||
const int x = 25;
|
const int x = 25;
|
||||||
const int y = 13;
|
const int y = 13;
|
||||||
spawnPoint = {x * 8, y * 8, 0, 0, 0, s_standing, SDL_FLIP_HORIZONTAL};
|
spawn_point_ = {x * 8, y * 8, 0, 0, 0, s_standing, SDL_FLIP_HORIZONTAL};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Crea los objetos
|
// Crea los objetos
|
||||||
cheevos = new Cheevos(screen, options, asset->get("cheevos.bin"));
|
cheevos_ = new Cheevos(screen_, options, asset_->get("cheevos.bin"));
|
||||||
scoreboard = new ScoreBoard(renderer, resource, asset, options, &board);
|
scoreboard_ = new ScoreBoard(renderer_, resource, asset_, options, &board_);
|
||||||
itemTracker = new ItemTracker();
|
item_tracker_ = new ItemTracker();
|
||||||
roomTracker = new RoomTracker();
|
room_tracker_ = new RoomTracker();
|
||||||
room = new Room(resource->getRoom(currentRoom), renderer, screen, asset, options, itemTracker, &board.items, false, debug);
|
room_ = new Room(resource->getRoom(current_room_), renderer_, screen_, asset_, options, item_tracker_, &board_.items, false, debug);
|
||||||
const std::string playerPNG = options->cheat.altSkin ? "player2.png" : "player.png";
|
const std::string playerPNG = options->cheat.altSkin ? "player2.png" : "player.png";
|
||||||
const std::string playerANI = options->cheat.altSkin ? "player2.ani" : "player.ani";
|
const std::string playerANI = options->cheat.altSkin ? "player2.ani" : "player.ani";
|
||||||
const player_t player = {spawnPoint, playerPNG, playerANI, renderer, resource, asset, options, input, room, debug};
|
const player_t player = {spawn_point_, playerPNG, playerANI, renderer_, resource, asset_, options, input_, room_, debug};
|
||||||
this->player = new Player(player);
|
this->player_ = new Player(player);
|
||||||
eventHandler = new SDL_Event();
|
event_handler_ = new SDL_Event();
|
||||||
text = new Text(resource->getOffset("smb2.txt"), resource->getTexture("smb2.png"), renderer);
|
text_ = new Text(resource->getOffset("smb2.txt"), resource->getTexture("smb2.png"), renderer_);
|
||||||
music = JA_LoadMusic(asset->get("game.ogg").c_str());
|
music_ = JA_LoadMusic(asset_->get("game.ogg").c_str());
|
||||||
deathSound = JA_LoadSound(asset->get("death.wav").c_str());
|
death_sound_ = JA_LoadSound(asset_->get("death.wav").c_str());
|
||||||
stats = new Stats(asset->get("stats.csv"), asset->get("stats_buffer.csv"), options);
|
stats_ = new Stats(asset_->get("stats.csv"), asset_->get("stats_buffer.csv"), options);
|
||||||
|
|
||||||
// Crea la textura para poner el nombre de la habitación
|
// Crea la textura para poner el nombre de la habitación
|
||||||
roomNameTexture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, GAMECANVAS_WIDTH, text->getCharacterSize() * 2);
|
room_name_texture_ = SDL_CreateTexture(renderer_, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, GAMECANVAS_WIDTH, text_->getCharacterSize() * 2);
|
||||||
if (roomNameTexture == nullptr)
|
if (room_name_texture_ == nullptr)
|
||||||
{
|
{
|
||||||
if (options->console)
|
if (options->console)
|
||||||
{
|
{
|
||||||
@@ -76,35 +74,35 @@ Game::Game(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *as
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Establece el blend mode de la textura
|
// Establece el blend mode de la textura
|
||||||
SDL_SetTextureBlendMode(roomNameTexture, SDL_BLENDMODE_BLEND);
|
SDL_SetTextureBlendMode(room_name_texture_, SDL_BLENDMODE_BLEND);
|
||||||
|
|
||||||
// Establece el destino de la textura
|
// Establece el destino de la textura
|
||||||
roomNameRect = {0, PLAY_AREA_HEIGHT, GAMECANVAS_WIDTH, text->getCharacterSize() * 2};
|
room_name_rect_ = {0, PLAY_AREA_HEIGHT, GAMECANVAS_WIDTH, text_->getCharacterSize() * 2};
|
||||||
|
|
||||||
// Pone el nombre de la habitación en la textura
|
// Pone el nombre de la habitación en la textura
|
||||||
fillRoomNameTexture();
|
fillRoomNameTexture();
|
||||||
|
|
||||||
// Inicializa el resto de variables
|
// Inicializa el resto de variables
|
||||||
ticks = 0;
|
ticks_ = 0;
|
||||||
ticksSpeed = 15;
|
ticks_speed_ = 15;
|
||||||
board.lives = 9;
|
board_.lives = 9;
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
board.lives = 9;
|
board_.lives = 9;
|
||||||
#endif
|
#endif
|
||||||
board.items = 0;
|
board_.items = 0;
|
||||||
board.rooms = 1;
|
board_.rooms = 1;
|
||||||
board.music = true;
|
board_.music = true;
|
||||||
board.jailEnabled = options->cheat.jailEnabled;
|
board_.jailEnabled = options->cheat.jailEnabled;
|
||||||
setScoreBoardColor();
|
setScoreBoardColor();
|
||||||
roomTracker->addRoom(currentRoom);
|
room_tracker_->addRoom(current_room_);
|
||||||
paused = false;
|
paused_ = false;
|
||||||
blackScreen = false;
|
black_screen_ = false;
|
||||||
blackScreenCounter = 0;
|
black_screen_counter_ = 0;
|
||||||
totalItems = getTotalItems();
|
total_items_ = getTotalItems();
|
||||||
initStats();
|
initStats();
|
||||||
stats->addVisit(room->getName());
|
stats_->addVisit(room_->getName());
|
||||||
const bool cheats = options->cheat.infiniteLives || options->cheat.invincible || options->cheat.jailEnabled;
|
const bool cheats = options->cheat.infiniteLives || options->cheat.invincible || options->cheat.jailEnabled;
|
||||||
cheevos->enable(!cheats); // Deshabilita los logros si hay trucos activados
|
cheevos_->enable(!cheats); // Deshabilita los logros si hay trucos activados
|
||||||
|
|
||||||
section->name = SECTION_GAME;
|
section->name = SECTION_GAME;
|
||||||
section->subsection = 0;
|
section->subsection = 0;
|
||||||
@@ -113,55 +111,55 @@ Game::Game(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *as
|
|||||||
Game::~Game()
|
Game::~Game()
|
||||||
{
|
{
|
||||||
// Libera la memoria de los objetos
|
// Libera la memoria de los objetos
|
||||||
delete cheevos;
|
delete cheevos_;
|
||||||
delete scoreboard;
|
delete scoreboard_;
|
||||||
delete itemTracker;
|
delete item_tracker_;
|
||||||
delete roomTracker;
|
delete room_tracker_;
|
||||||
delete room;
|
delete room_;
|
||||||
delete player;
|
delete player_;
|
||||||
delete eventHandler;
|
delete event_handler_;
|
||||||
delete text;
|
delete text_;
|
||||||
delete stats;
|
delete stats_;
|
||||||
|
|
||||||
SDL_DestroyTexture(roomNameTexture);
|
SDL_DestroyTexture(room_name_texture_);
|
||||||
|
|
||||||
JA_DeleteMusic(music);
|
JA_DeleteMusic(music_);
|
||||||
JA_DeleteSound(deathSound);
|
JA_DeleteSound(death_sound_);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Comprueba los eventos de la cola
|
// Comprueba los eventos de la cola
|
||||||
void Game::checkEvents()
|
void Game::checkEvents()
|
||||||
{
|
{
|
||||||
// Comprueba los eventos que hay en la cola
|
// Comprueba los eventos que hay en la cola
|
||||||
while (SDL_PollEvent(eventHandler) != 0)
|
while (SDL_PollEvent(event_handler_) != 0)
|
||||||
{
|
{
|
||||||
// Evento de salida de la aplicación
|
// Evento de salida de la aplicación
|
||||||
if (eventHandler->type == SDL_QUIT)
|
if (event_handler_->type == SDL_QUIT)
|
||||||
{
|
{
|
||||||
section->name = SECTION_QUIT;
|
section_->name = SECTION_QUIT;
|
||||||
screen->setBorderColor(stringToColor(options->palette, "black"));
|
screen_->setBorderColor(stringToColor(options_->palette, "black"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (eventHandler->type == SDL_RENDER_DEVICE_RESET || eventHandler->type == SDL_RENDER_TARGETS_RESET)
|
if (event_handler_->type == SDL_RENDER_DEVICE_RESET || event_handler_->type == SDL_RENDER_TARGETS_RESET)
|
||||||
{
|
{
|
||||||
reLoadTextures();
|
reLoadTextures();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (eventHandler->type == SDL_KEYDOWN && eventHandler->key.repeat == 0)
|
if (event_handler_->type == SDL_KEYDOWN && event_handler_->key.repeat == 0)
|
||||||
{
|
{
|
||||||
switch (eventHandler->key.keysym.scancode)
|
switch (event_handler_->key.keysym.scancode)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
case SDL_SCANCODE_G:
|
case SDL_SCANCODE_G:
|
||||||
debug->switchEnabled();
|
debug_->switchEnabled();
|
||||||
options->cheat.invincible = debug->getEnabled();
|
options_->cheat.invincible = debug_->getEnabled();
|
||||||
board.music = !debug->getEnabled();
|
board_.music = !debug_->getEnabled();
|
||||||
board.music ? JA_ResumeMusic() : JA_PauseMusic();
|
board_.music ? JA_ResumeMusic() : JA_PauseMusic();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDL_SCANCODE_R:
|
case SDL_SCANCODE_R:
|
||||||
resource->reLoad();
|
resource_->reLoad();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDL_SCANCODE_W:
|
case SDL_SCANCODE_W:
|
||||||
@@ -181,19 +179,19 @@ void Game::checkEvents()
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case SDL_SCANCODE_F6:
|
case SDL_SCANCODE_F6:
|
||||||
screen->showNotification("ACHIEVEMENT UNLOCKED!", "I LIKE MY MULTICOLOURED FRIENDS", 2);
|
screen_->showNotification("ACHIEVEMENT UNLOCKED!", "I LIKE MY MULTICOLOURED FRIENDS", 2);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDL_SCANCODE_F7:
|
case SDL_SCANCODE_F7:
|
||||||
screen->showNotification("ACHIEVEMENT UNLOCKED!", "I LIKE MY MULTICOLOURED FRIENDS", 3);
|
screen_->showNotification("ACHIEVEMENT UNLOCKED!", "I LIKE MY MULTICOLOURED FRIENDS", 3);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDL_SCANCODE_F8:
|
case SDL_SCANCODE_F8:
|
||||||
screen->showNotification("JAILDESIGNER IS LOGGED IN", "", 4);
|
screen_->showNotification("JAILDESIGNER IS LOGGED IN", "", 4);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDL_SCANCODE_F9:
|
case SDL_SCANCODE_F9:
|
||||||
screen->showNotification("JAILDESIGNER IS LOGGED IN", "", 5);
|
screen_->showNotification("JAILDESIGNER IS LOGGED IN", "", 5);
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
default:
|
default:
|
||||||
@@ -206,52 +204,52 @@ void Game::checkEvents()
|
|||||||
// Comprueba el teclado
|
// Comprueba el teclado
|
||||||
void Game::checkInput()
|
void Game::checkInput()
|
||||||
{
|
{
|
||||||
if (input->checkInput(input_exit, REPEAT_FALSE))
|
if (input_->checkInput(input_exit, REPEAT_FALSE))
|
||||||
{
|
{
|
||||||
section->name = SECTION_TITLE;
|
section_->name = SECTION_TITLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (input->checkInput(input_toggle_music, REPEAT_FALSE))
|
else if (input_->checkInput(input_toggle_music, REPEAT_FALSE))
|
||||||
{
|
{
|
||||||
board.music = !board.music;
|
board_.music = !board_.music;
|
||||||
board.music ? JA_ResumeMusic() : JA_PauseMusic();
|
board_.music ? JA_ResumeMusic() : JA_PauseMusic();
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (input->checkInput(input_pause, REPEAT_FALSE))
|
else if (input_->checkInput(input_pause, REPEAT_FALSE))
|
||||||
{
|
{
|
||||||
switchPause();
|
switchPause();
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (input->checkInput(input_toggle_border, REPEAT_FALSE))
|
else if (input_->checkInput(input_toggle_border, REPEAT_FALSE))
|
||||||
{
|
{
|
||||||
screen->toggleBorder();
|
screen_->toggleBorder();
|
||||||
reLoadTextures();
|
reLoadTextures();
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (input->checkInput(input_toggle_videomode, REPEAT_FALSE))
|
else if (input_->checkInput(input_toggle_videomode, REPEAT_FALSE))
|
||||||
{
|
{
|
||||||
screen->toggleVideoMode();
|
screen_->toggleVideoMode();
|
||||||
reLoadTextures();
|
reLoadTextures();
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (input->checkInput(input_toggle_shaders, REPEAT_FALSE))
|
else if (input_->checkInput(input_toggle_shaders, REPEAT_FALSE))
|
||||||
{
|
{
|
||||||
screen->toggleShaders();
|
screen_->toggleShaders();
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (input->checkInput(input_window_dec_size, REPEAT_FALSE))
|
else if (input_->checkInput(input_window_dec_size, REPEAT_FALSE))
|
||||||
{
|
{
|
||||||
screen->decWindowSize();
|
screen_->decWindowSize();
|
||||||
reLoadTextures();
|
reLoadTextures();
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (input->checkInput(input_window_inc_size, REPEAT_FALSE))
|
else if (input_->checkInput(input_window_inc_size, REPEAT_FALSE))
|
||||||
{
|
{
|
||||||
screen->incWindowSize();
|
screen_->incWindowSize();
|
||||||
reLoadTextures();
|
reLoadTextures();
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (input->checkInput(input_toggle_palette, REPEAT_FALSE))
|
else if (input_->checkInput(input_toggle_palette, REPEAT_FALSE))
|
||||||
{
|
{
|
||||||
switchPalette();
|
switchPalette();
|
||||||
}
|
}
|
||||||
@@ -260,13 +258,13 @@ void Game::checkInput()
|
|||||||
// Bucle para el juego
|
// Bucle para el juego
|
||||||
void Game::run()
|
void Game::run()
|
||||||
{
|
{
|
||||||
JA_PlayMusic(music);
|
JA_PlayMusic(music_);
|
||||||
if (!board.music)
|
if (!board_.music)
|
||||||
{
|
{
|
||||||
JA_PauseMusic();
|
JA_PauseMusic();
|
||||||
}
|
}
|
||||||
|
|
||||||
while (section->name == SECTION_GAME)
|
while (section_->name == SECTION_GAME)
|
||||||
{
|
{
|
||||||
update();
|
update();
|
||||||
checkEvents();
|
checkEvents();
|
||||||
@@ -280,21 +278,21 @@ void Game::run()
|
|||||||
void Game::update()
|
void Game::update()
|
||||||
{
|
{
|
||||||
// Comprueba que la diferencia de ticks sea mayor a la velocidad del juego
|
// Comprueba que la diferencia de ticks sea mayor a la velocidad del juego
|
||||||
if (SDL_GetTicks() - ticks > ticksSpeed)
|
if (SDL_GetTicks() - ticks_ > ticks_speed_)
|
||||||
{
|
{
|
||||||
// Actualiza el contador de ticks
|
// Actualiza el contador de ticks
|
||||||
ticks = SDL_GetTicks();
|
ticks_ = SDL_GetTicks();
|
||||||
|
|
||||||
// Comprueba el teclado
|
// Comprueba el teclado
|
||||||
checkInput();
|
checkInput();
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
debug->clear();
|
debug_->clear();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Actualiza los objetos
|
// Actualiza los objetos
|
||||||
room->update();
|
room_->update();
|
||||||
player->update();
|
player_->update();
|
||||||
checkPlayerOnBorder();
|
checkPlayerOnBorder();
|
||||||
checkPlayerAndItems();
|
checkPlayerAndItems();
|
||||||
checkPlayerAndEnemies();
|
checkPlayerAndEnemies();
|
||||||
@@ -303,13 +301,13 @@ void Game::update()
|
|||||||
checkEndGame();
|
checkEndGame();
|
||||||
checkRestoringJail();
|
checkRestoringJail();
|
||||||
checkSomeCheevos();
|
checkSomeCheevos();
|
||||||
scoreboard->update();
|
scoreboard_->update();
|
||||||
input->update();
|
input_->update();
|
||||||
|
|
||||||
updateBlackScreen();
|
updateBlackScreen();
|
||||||
|
|
||||||
// Actualiza las notificaciones
|
// Actualiza las notificaciones
|
||||||
screen->updateNotifier();
|
screen_->updateNotifier();
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
updateDebugInfo();
|
updateDebugInfo();
|
||||||
@@ -321,15 +319,15 @@ void Game::update()
|
|||||||
void Game::render()
|
void Game::render()
|
||||||
{
|
{
|
||||||
// Prepara para dibujar el frame
|
// Prepara para dibujar el frame
|
||||||
screen->start();
|
screen_->start();
|
||||||
|
|
||||||
// Dibuja los elementos del juego en orden
|
// Dibuja los elementos del juego en orden
|
||||||
room->renderMap();
|
room_->renderMap();
|
||||||
room->renderEnemies();
|
room_->renderEnemies();
|
||||||
room->renderItems();
|
room_->renderItems();
|
||||||
player->render();
|
player_->render();
|
||||||
renderRoomName();
|
renderRoomName();
|
||||||
scoreboard->render();
|
scoreboard_->render();
|
||||||
renderBlackScreen();
|
renderBlackScreen();
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
@@ -338,45 +336,45 @@ void Game::render()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Actualiza la pantalla
|
// Actualiza la pantalla
|
||||||
screen->render();
|
screen_->render();
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
// Pasa la información de debug
|
// Pasa la información de debug
|
||||||
void Game::updateDebugInfo()
|
void Game::updateDebugInfo()
|
||||||
{
|
{
|
||||||
debug->add("X = " + std::to_string((int)player->x) + ", Y = " + std::to_string((int)player->y));
|
debug_->add("X = " + std::to_string(static_cast<int>(player_->x)) + ", Y = " + std::to_string(static_cast<int>(player_->y)));
|
||||||
debug->add("VX = " + std::to_string(player->vx).substr(0, 4) + ", VY = " + std::to_string(player->vy).substr(0, 4));
|
debug_->add("VX = " + std::to_string(player_->vx).substr(0, 4) + ", VY = " + std::to_string(player_->vy).substr(0, 4));
|
||||||
debug->add("STATE = " + std::to_string(player->state));
|
debug_->add("STATE = " + std::to_string(player_->state));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pone la información de debug en pantalla
|
// Pone la información de debug en pantalla
|
||||||
void Game::renderDebugInfo()
|
void Game::renderDebugInfo()
|
||||||
{
|
{
|
||||||
if (!debug->getEnabled())
|
if (!debug_->getEnabled())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Borra el marcador
|
// Borra el marcador
|
||||||
SDL_Rect rect = {0, 18 * BLOCK, PLAY_AREA_WIDTH, GAMECANVAS_HEIGHT - PLAY_AREA_HEIGHT};
|
SDL_Rect rect = {0, 18 * BLOCK, PLAY_AREA_WIDTH, GAMECANVAS_HEIGHT - PLAY_AREA_HEIGHT};
|
||||||
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
|
SDL_SetRenderDrawColor(renderer_, 0, 0, 0, 255);
|
||||||
SDL_RenderFillRect(renderer, &rect);
|
SDL_RenderFillRect(renderer_, &rect);
|
||||||
|
|
||||||
// Pinta la rejilla
|
// Pinta la rejilla
|
||||||
SDL_SetRenderDrawColor(renderer, 255, 255, 255, 32);
|
SDL_SetRenderDrawColor(renderer_, 255, 255, 255, 32);
|
||||||
for (int i = 0; i < PLAY_AREA_BOTTOM; i += 8)
|
for (int i = 0; i < PLAY_AREA_BOTTOM; i += 8)
|
||||||
{ // Lineas horizontales
|
{ // Lineas horizontales
|
||||||
SDL_RenderDrawLine(renderer, 0, i, PLAY_AREA_RIGHT, i);
|
SDL_RenderDrawLine(renderer_, 0, i, PLAY_AREA_RIGHT, i);
|
||||||
}
|
}
|
||||||
for (int i = 0; i < PLAY_AREA_RIGHT; i += 8)
|
for (int i = 0; i < PLAY_AREA_RIGHT; i += 8)
|
||||||
{ // Lineas verticales
|
{ // Lineas verticales
|
||||||
SDL_RenderDrawLine(renderer, i, 0, i, PLAY_AREA_BOTTOM - 1);
|
SDL_RenderDrawLine(renderer_, i, 0, i, PLAY_AREA_BOTTOM - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pinta el texto
|
// Pinta el texto
|
||||||
debug->setPos({1, 18 * 8});
|
debug_->setPos({1, 18 * 8});
|
||||||
debug->render();
|
debug_->render();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -384,7 +382,7 @@ void Game::renderDebugInfo()
|
|||||||
void Game::renderRoomName()
|
void Game::renderRoomName()
|
||||||
{
|
{
|
||||||
// Dibuja la textura con el nombre de la habitación
|
// Dibuja la textura con el nombre de la habitación
|
||||||
SDL_RenderCopy(renderer, roomNameTexture, nullptr, &roomNameRect);
|
SDL_RenderCopy(renderer_, room_name_texture_, nullptr, &room_name_rect_);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cambia de habitación
|
// Cambia de habitación
|
||||||
@@ -397,14 +395,14 @@ bool Game::changeRoom(std::string file)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Verifica que exista el fichero que se va a cargar
|
// Verifica que exista el fichero que se va a cargar
|
||||||
if (asset->get(file) != "")
|
if (asset_->get(file) != "")
|
||||||
{
|
{
|
||||||
// Elimina la habitación actual
|
// Elimina la habitación actual
|
||||||
delete room;
|
delete room_;
|
||||||
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(resource->getRoom(file), renderer, screen, asset, options, itemTracker, &board.items, board.jailEnabled, debug);
|
room_ = new Room(resource_->getRoom(file), renderer_, screen_, asset_, options_, item_tracker_, &board_.items, board_.jailEnabled, debug_);
|
||||||
|
|
||||||
// Pone el nombre de la habitación en la textura
|
// Pone el nombre de la habitación en la textura
|
||||||
fillRoomNameTexture();
|
fillRoomNameTexture();
|
||||||
@@ -412,18 +410,18 @@ bool Game::changeRoom(std::string file)
|
|||||||
// Pone el color del marcador en función del color del borde de la habitación
|
// Pone el color del marcador en función del color del borde de la habitación
|
||||||
setScoreBoardColor();
|
setScoreBoardColor();
|
||||||
|
|
||||||
if (roomTracker->addRoom(file))
|
if (room_tracker_->addRoom(file))
|
||||||
{
|
{
|
||||||
// Incrementa el contador de habitaciones visitadas
|
// Incrementa el contador de habitaciones visitadas
|
||||||
board.rooms++;
|
board_.rooms++;
|
||||||
options->stats.rooms = board.rooms;
|
options_->stats.rooms = board_.rooms;
|
||||||
|
|
||||||
// Actualiza las estadisticas
|
// Actualiza las estadisticas
|
||||||
stats->addVisit(room->getName());
|
stats_->addVisit(room_->getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pasa la nueva habitación al jugador
|
// Pasa la nueva habitación al jugador
|
||||||
player->setRoom(room);
|
player_->setRoom(room_);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -434,14 +432,14 @@ bool Game::changeRoom(std::string file)
|
|||||||
// Comprueba si el jugador esta en el borde de la pantalla
|
// Comprueba si el jugador esta en el borde de la pantalla
|
||||||
void Game::checkPlayerOnBorder()
|
void Game::checkPlayerOnBorder()
|
||||||
{
|
{
|
||||||
if (player->getOnBorder())
|
if (player_->getOnBorder())
|
||||||
{
|
{
|
||||||
const std::string roomName = room->getRoom(player->getBorder());
|
const std::string roomName = room_->getRoom(player_->getBorder());
|
||||||
if (changeRoom(roomName))
|
if (changeRoom(roomName))
|
||||||
{
|
{
|
||||||
player->switchBorders();
|
player_->switchBorders();
|
||||||
currentRoom = roomName;
|
current_room_ = roomName;
|
||||||
spawnPoint = player->getSpawnParams();
|
spawn_point_ = player_->getSpawnParams();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -449,7 +447,7 @@ void Game::checkPlayerOnBorder()
|
|||||||
// Comprueba las colisiones del jugador con los enemigos
|
// Comprueba las colisiones del jugador con los enemigos
|
||||||
bool Game::checkPlayerAndEnemies()
|
bool Game::checkPlayerAndEnemies()
|
||||||
{
|
{
|
||||||
const bool death = room->enemyCollision(player->getCollider());
|
const bool death = room_->enemyCollision(player_->getCollider());
|
||||||
if (death)
|
if (death)
|
||||||
{
|
{
|
||||||
killPlayer();
|
killPlayer();
|
||||||
@@ -460,13 +458,13 @@ bool Game::checkPlayerAndEnemies()
|
|||||||
// Comprueba las colisiones del jugador con los objetos
|
// Comprueba las colisiones del jugador con los objetos
|
||||||
void Game::checkPlayerAndItems()
|
void Game::checkPlayerAndItems()
|
||||||
{
|
{
|
||||||
room->itemCollision(player->getCollider());
|
room_->itemCollision(player_->getCollider());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Comprueba si el jugador esta vivo
|
// Comprueba si el jugador esta vivo
|
||||||
void Game::checkIfPlayerIsAlive()
|
void Game::checkIfPlayerIsAlive()
|
||||||
{
|
{
|
||||||
if (!player->isAlive())
|
if (!player_->isAlive())
|
||||||
{
|
{
|
||||||
killPlayer();
|
killPlayer();
|
||||||
}
|
}
|
||||||
@@ -475,82 +473,82 @@ void Game::checkIfPlayerIsAlive()
|
|||||||
// Comprueba si ha terminado la partida
|
// Comprueba si ha terminado la partida
|
||||||
void Game::checkGameOver()
|
void Game::checkGameOver()
|
||||||
{
|
{
|
||||||
if (board.lives < 0 && blackScreenCounter > 17)
|
if (board_.lives < 0 && black_screen_counter_ > 17)
|
||||||
{
|
{
|
||||||
section->name = SECTION_GAME_OVER;
|
section_->name = SECTION_GAME_OVER;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mata al jugador
|
// Mata al jugador
|
||||||
void Game::killPlayer()
|
void Game::killPlayer()
|
||||||
{
|
{
|
||||||
if (options->cheat.invincible)
|
if (options_->cheat.invincible)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Resta una vida al jugador
|
// Resta una vida al jugador
|
||||||
if (!options->cheat.infiniteLives)
|
if (!options_->cheat.infiniteLives)
|
||||||
{
|
{
|
||||||
board.lives--;
|
board_.lives--;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actualiza las estadisticas
|
// Actualiza las estadisticas
|
||||||
stats->addDeath(room->getName());
|
stats_->addDeath(room_->getName());
|
||||||
|
|
||||||
// Invalida el logro de pasarse el juego sin morir
|
// Invalida el logro de pasarse el juego sin morir
|
||||||
cheevos->invalidate(11);
|
cheevos_->invalidate(11);
|
||||||
|
|
||||||
// Destruye la habitacion y el jugador
|
// Destruye la habitacion y el jugador
|
||||||
delete room;
|
delete room_;
|
||||||
delete this->player;
|
delete this->player_;
|
||||||
|
|
||||||
// Sonido
|
// Sonido
|
||||||
JA_PlaySound(deathSound);
|
JA_PlaySound(death_sound_);
|
||||||
|
|
||||||
// Pone la pantalla en negro un tiempo
|
// Pone la pantalla en negro un tiempo
|
||||||
setBlackScreen();
|
setBlackScreen();
|
||||||
|
|
||||||
// Crea la nueva habitación y el nuevo jugador
|
// Crea la nueva habitación y el nuevo jugador
|
||||||
room = new Room(resource->getRoom(currentRoom), renderer, screen, asset, options, itemTracker, &board.items, board.jailEnabled, debug);
|
room_ = new Room(resource_->getRoom(current_room_), renderer_, screen_, asset_, options_, item_tracker_, &board_.items, board_.jailEnabled, debug_);
|
||||||
const std::string playerPNG = options->cheat.altSkin ? "player2.png" : "player.png";
|
const std::string playerPNG = options_->cheat.altSkin ? "player2.png" : "player.png";
|
||||||
const std::string playerANI = options->cheat.altSkin ? "player2.ani" : "player.ani";
|
const std::string playerANI = options_->cheat.altSkin ? "player2.ani" : "player.ani";
|
||||||
const player_t player = {spawnPoint, playerPNG, playerANI, renderer, resource, asset, options, input, room, debug};
|
const player_t player = {spawn_point_, playerPNG, playerANI, renderer_, resource_, asset_, options_, input_, room_, debug_};
|
||||||
this->player = new Player(player);
|
this->player_ = new Player(player);
|
||||||
|
|
||||||
// Pone los objetos en pausa mientras esta la habitación en negro
|
// Pone los objetos en pausa mientras esta la habitación en negro
|
||||||
room->pause();
|
room_->pause();
|
||||||
this->player->pause();
|
this->player_->pause();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Recarga todas las texturas
|
// Recarga todas las texturas
|
||||||
void Game::reLoadTextures()
|
void Game::reLoadTextures()
|
||||||
{
|
{
|
||||||
if (options->console)
|
if (options_->console)
|
||||||
{
|
{
|
||||||
std::cout << "** RELOAD REQUESTED" << std::endl;
|
std::cout << "** RELOAD REQUESTED" << std::endl;
|
||||||
}
|
}
|
||||||
player->reLoadTexture();
|
player_->reLoadTexture();
|
||||||
room->reLoadTexture();
|
room_->reLoadTexture();
|
||||||
scoreboard->reLoadTexture();
|
scoreboard_->reLoadTexture();
|
||||||
text->reLoadTexture();
|
text_->reLoadTexture();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cambia la paleta
|
// Cambia la paleta
|
||||||
void Game::switchPalette()
|
void Game::switchPalette()
|
||||||
{
|
{
|
||||||
if (options->console)
|
if (options_->console)
|
||||||
{
|
{
|
||||||
std::cout << "** PALETTE SWITCH REQUESTED" << std::endl;
|
std::cout << "** PALETTE SWITCH REQUESTED" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Modifica la variable
|
// Modifica la variable
|
||||||
options->palette = (options->palette == p_zxspectrum) ? p_zxarne : p_zxspectrum;
|
options_->palette = (options_->palette == p_zxspectrum) ? p_zxarne : p_zxspectrum;
|
||||||
|
|
||||||
// Recarga las paletas
|
// Recarga las paletas
|
||||||
room->reLoadPalette();
|
room_->reLoadPalette();
|
||||||
player->reLoadPalette();
|
player_->reLoadPalette();
|
||||||
scoreboard->reLoadPalette();
|
scoreboard_->reLoadPalette();
|
||||||
|
|
||||||
// Pone el color del marcador en función del color del borde de la habitación
|
// Pone el color del marcador en función del color del borde de la habitación
|
||||||
setScoreBoardColor();
|
setScoreBoardColor();
|
||||||
@@ -559,23 +557,23 @@ void Game::switchPalette()
|
|||||||
// Establece la pantalla en negro
|
// Establece la pantalla en negro
|
||||||
void Game::setBlackScreen()
|
void Game::setBlackScreen()
|
||||||
{
|
{
|
||||||
blackScreen = true;
|
black_screen_ = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actualiza las variables relativas a la pantalla en negro
|
// Actualiza las variables relativas a la pantalla en negro
|
||||||
void Game::updateBlackScreen()
|
void Game::updateBlackScreen()
|
||||||
{
|
{
|
||||||
if (blackScreen)
|
if (black_screen_)
|
||||||
{
|
{
|
||||||
blackScreenCounter++;
|
black_screen_counter_++;
|
||||||
if (blackScreenCounter > 20)
|
if (black_screen_counter_ > 20)
|
||||||
{
|
{
|
||||||
blackScreen = false;
|
black_screen_ = false;
|
||||||
blackScreenCounter = 0;
|
black_screen_counter_ = 0;
|
||||||
|
|
||||||
player->resume();
|
player_->resume();
|
||||||
room->resume();
|
room_->resume();
|
||||||
screen->setBorderColor(room->getBorderColor());
|
screen_->setBorderColor(room_->getBorderColor());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -583,10 +581,10 @@ void Game::updateBlackScreen()
|
|||||||
// Dibuja la pantalla negra
|
// Dibuja la pantalla negra
|
||||||
void Game::renderBlackScreen()
|
void Game::renderBlackScreen()
|
||||||
{
|
{
|
||||||
if (blackScreen)
|
if (black_screen_)
|
||||||
{
|
{
|
||||||
screen->clean();
|
screen_->clean();
|
||||||
screen->setBorderColor(stringToColor(options->palette, "black"));
|
screen_->setBorderColor(stringToColor(options_->palette, "black"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -594,25 +592,25 @@ void Game::renderBlackScreen()
|
|||||||
void Game::setScoreBoardColor()
|
void Game::setScoreBoardColor()
|
||||||
{
|
{
|
||||||
// Obtiene el color del borde
|
// Obtiene el color del borde
|
||||||
const color_t colorBorder = room->getBorderColor();
|
const color_t colorBorder = room_->getBorderColor();
|
||||||
|
|
||||||
const bool isBlack = colorAreEqual(colorBorder, stringToColor(options->palette, "black"));
|
const bool isBlack = colorAreEqual(colorBorder, stringToColor(options_->palette, "black"));
|
||||||
const bool isBrightBlack = colorAreEqual(colorBorder, stringToColor(options->palette, "bright_black"));
|
const bool isBrightBlack = colorAreEqual(colorBorder, stringToColor(options_->palette, "bright_black"));
|
||||||
|
|
||||||
// Si el color del borde es negro o negro brillante cambia el texto del marcador a blanco
|
// Si el color del borde es negro o negro brillante cambia el texto del marcador a blanco
|
||||||
board.color = isBlack || isBrightBlack ? stringToColor(options->palette, "white") : colorBorder;
|
board_.color = isBlack || isBrightBlack ? stringToColor(options_->palette, "white") : colorBorder;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Comprueba si ha finalizado el juego
|
// Comprueba si ha finalizado el juego
|
||||||
bool Game::checkEndGame()
|
bool Game::checkEndGame()
|
||||||
{
|
{
|
||||||
const bool isOnTheRoom = room->getName() == "THE JAIL"; // Estar en la habitación que toca
|
const bool isOnTheRoom = room_->getName() == "THE JAIL"; // Estar en la habitación que toca
|
||||||
const bool haveTheItems = board.items >= int(totalItems * 0.9f) || options->cheat.jailEnabled; // Con mas del 90% de los items recogidos
|
const bool haveTheItems = board_.items >= int(total_items_ * 0.9f) || options_->cheat.jailEnabled; // Con mas del 90% de los items recogidos
|
||||||
const bool isOnTheDoor = player->getRect().x <= 128; // Y en la ubicación que toca (En la puerta)
|
const bool isOnTheDoor = player_->getRect().x <= 128; // Y en la ubicación que toca (En la puerta)
|
||||||
|
|
||||||
if (haveTheItems)
|
if (haveTheItems)
|
||||||
{
|
{
|
||||||
board.jailEnabled = true;
|
board_.jailEnabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (haveTheItems && isOnTheRoom && isOnTheDoor)
|
if (haveTheItems && isOnTheRoom && isOnTheDoor)
|
||||||
@@ -620,7 +618,7 @@ bool Game::checkEndGame()
|
|||||||
// Comprueba los logros de completar el juego
|
// Comprueba los logros de completar el juego
|
||||||
checkEndGameCheevos();
|
checkEndGameCheevos();
|
||||||
|
|
||||||
section->name = SECTION_ENDING;
|
section_->name = SECTION_ENDING;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -632,7 +630,7 @@ int Game::getTotalItems()
|
|||||||
{
|
{
|
||||||
int items = 0;
|
int items = 0;
|
||||||
std::vector<res_room_t> *rooms = new std::vector<res_room_t>;
|
std::vector<res_room_t> *rooms = new std::vector<res_room_t>;
|
||||||
rooms = resource->getAllRooms();
|
rooms = resource_->getAllRooms();
|
||||||
|
|
||||||
for (auto room : *rooms)
|
for (auto room : *rooms)
|
||||||
{
|
{
|
||||||
@@ -645,43 +643,43 @@ int Game::getTotalItems()
|
|||||||
// Va a la habitación designada
|
// Va a la habitación designada
|
||||||
void Game::goToRoom(int border)
|
void Game::goToRoom(int border)
|
||||||
{
|
{
|
||||||
const std::string roomName = room->getRoom(border);
|
const std::string roomName = room_->getRoom(border);
|
||||||
if (changeRoom(roomName))
|
if (changeRoom(roomName))
|
||||||
{
|
{
|
||||||
currentRoom = roomName;
|
current_room_ = roomName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pone el juego en pausa
|
// Pone el juego en pausa
|
||||||
void Game::switchPause()
|
void Game::switchPause()
|
||||||
{
|
{
|
||||||
if (paused)
|
if (paused_)
|
||||||
{
|
{
|
||||||
player->resume();
|
player_->resume();
|
||||||
room->resume();
|
room_->resume();
|
||||||
scoreboard->resume();
|
scoreboard_->resume();
|
||||||
paused = false;
|
paused_ = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
player->pause();
|
player_->pause();
|
||||||
room->pause();
|
room_->pause();
|
||||||
scoreboard->pause();
|
scoreboard_->pause();
|
||||||
paused = true;
|
paused_ = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Da vidas al jugador cuando está en la Jail
|
// Da vidas al jugador cuando está en la Jail
|
||||||
void Game::checkRestoringJail()
|
void Game::checkRestoringJail()
|
||||||
{
|
{
|
||||||
if (room->getName() != "THE JAIL" || board.lives == 9)
|
if (room_->getName() != "THE JAIL" || board_.lives == 9)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int counter = 0;
|
static int counter = 0;
|
||||||
|
|
||||||
if (!paused)
|
if (!paused_)
|
||||||
{
|
{
|
||||||
counter++;
|
counter++;
|
||||||
}
|
}
|
||||||
@@ -690,14 +688,14 @@ void Game::checkRestoringJail()
|
|||||||
if (counter == 100)
|
if (counter == 100)
|
||||||
{
|
{
|
||||||
counter = 0;
|
counter = 0;
|
||||||
board.lives++;
|
board_.lives++;
|
||||||
JA_PlaySound(deathSound);
|
JA_PlaySound(death_sound_);
|
||||||
|
|
||||||
// Invalida el logro de completar el juego sin entrar a la jail
|
// Invalida el logro de completar el juego sin entrar a la jail
|
||||||
const bool haveTheItems = board.items >= int(totalItems * 0.9f);
|
const bool haveTheItems = board_.items >= int(total_items_ * 0.9f);
|
||||||
if (!haveTheItems)
|
if (!haveTheItems)
|
||||||
{
|
{
|
||||||
cheevos->invalidate(9);
|
cheevos_->invalidate(9);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -706,76 +704,76 @@ void Game::checkRestoringJail()
|
|||||||
void Game::initStats()
|
void Game::initStats()
|
||||||
{
|
{
|
||||||
std::vector<res_room_t> *rooms = new std::vector<res_room_t>;
|
std::vector<res_room_t> *rooms = new std::vector<res_room_t>;
|
||||||
rooms = resource->getAllRooms();
|
rooms = resource_->getAllRooms();
|
||||||
|
|
||||||
for (auto room : *rooms)
|
for (auto room : *rooms)
|
||||||
{
|
{
|
||||||
stats->addDictionary(room.room->number, room.room->name);
|
stats_->addDictionary(room.room->number, room.room->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
stats->init();
|
stats_->init();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Crea la textura con el nombre de la habitación
|
// Crea la textura con el nombre de la habitación
|
||||||
void Game::fillRoomNameTexture()
|
void Game::fillRoomNameTexture()
|
||||||
{
|
{
|
||||||
// Pone la textura como destino de renderizado
|
// Pone la textura como destino de renderizado
|
||||||
SDL_SetRenderTarget(renderer, roomNameTexture);
|
SDL_SetRenderTarget(renderer_, room_name_texture_);
|
||||||
|
|
||||||
// Rellena la textura de color
|
// Rellena la textura de color
|
||||||
const color_t color = stringToColor(options->palette, "white");
|
const 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_RenderClear(renderer);
|
SDL_RenderClear(renderer_);
|
||||||
|
|
||||||
// Escribe el texto en la textura
|
// Escribe el texto en la textura
|
||||||
text->writeDX(TXT_CENTER | TXT_COLOR, GAMECANVAS_CENTER_X, text->getCharacterSize() / 2, room->getName(), 1, room->getBGColor());
|
text_->writeDX(TXT_CENTER | TXT_COLOR, GAMECANVAS_CENTER_X, text_->getCharacterSize() / 2, room_->getName(), 1, room_->getBGColor());
|
||||||
|
|
||||||
// Deja el renderizador por defecto
|
// Deja el renderizador por defecto
|
||||||
SDL_SetRenderTarget(renderer, nullptr);
|
SDL_SetRenderTarget(renderer_, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Comprueba algunos logros
|
// Comprueba algunos logros
|
||||||
void Game::checkSomeCheevos()
|
void Game::checkSomeCheevos()
|
||||||
{
|
{
|
||||||
// Logros sobre la cantidad de items
|
// Logros sobre la cantidad de items
|
||||||
if (board.items == totalItems)
|
if (board_.items == total_items_)
|
||||||
{
|
{
|
||||||
cheevos->unlock(4);
|
cheevos_->unlock(4);
|
||||||
cheevos->unlock(3);
|
cheevos_->unlock(3);
|
||||||
cheevos->unlock(2);
|
cheevos_->unlock(2);
|
||||||
cheevos->unlock(1);
|
cheevos_->unlock(1);
|
||||||
}
|
}
|
||||||
else if (board.items >= totalItems * 0.75f)
|
else if (board_.items >= total_items_ * 0.75f)
|
||||||
{
|
{
|
||||||
cheevos->unlock(3);
|
cheevos_->unlock(3);
|
||||||
cheevos->unlock(2);
|
cheevos_->unlock(2);
|
||||||
cheevos->unlock(1);
|
cheevos_->unlock(1);
|
||||||
}
|
}
|
||||||
else if (board.items >= totalItems * 0.5f)
|
else if (board_.items >= total_items_ * 0.5f)
|
||||||
{
|
{
|
||||||
cheevos->unlock(2);
|
cheevos_->unlock(2);
|
||||||
cheevos->unlock(1);
|
cheevos_->unlock(1);
|
||||||
}
|
}
|
||||||
else if (board.items >= totalItems * 0.25f)
|
else if (board_.items >= total_items_ * 0.25f)
|
||||||
{
|
{
|
||||||
cheevos->unlock(1);
|
cheevos_->unlock(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Logros sobre las habitaciones visitadas
|
// Logros sobre las habitaciones visitadas
|
||||||
if (board.rooms >= 60)
|
if (board_.rooms >= 60)
|
||||||
{
|
{
|
||||||
cheevos->unlock(7);
|
cheevos_->unlock(7);
|
||||||
cheevos->unlock(6);
|
cheevos_->unlock(6);
|
||||||
cheevos->unlock(5);
|
cheevos_->unlock(5);
|
||||||
}
|
}
|
||||||
else if (board.rooms >= 40)
|
else if (board_.rooms >= 40)
|
||||||
{
|
{
|
||||||
cheevos->unlock(6);
|
cheevos_->unlock(6);
|
||||||
cheevos->unlock(5);
|
cheevos_->unlock(5);
|
||||||
}
|
}
|
||||||
else if (board.rooms >= 20)
|
else if (board_.rooms >= 20)
|
||||||
{
|
{
|
||||||
cheevos->unlock(5);
|
cheevos_->unlock(5);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -783,23 +781,23 @@ void Game::checkSomeCheevos()
|
|||||||
void Game::checkEndGameCheevos()
|
void Game::checkEndGameCheevos()
|
||||||
{
|
{
|
||||||
// "Complete the game"
|
// "Complete the game"
|
||||||
cheevos->unlock(8);
|
cheevos_->unlock(8);
|
||||||
|
|
||||||
// "Complete the game without entering the jail"
|
// "Complete the game without entering the jail"
|
||||||
cheevos->unlock(9);
|
cheevos_->unlock(9);
|
||||||
|
|
||||||
// "Complete the game with all items"
|
// "Complete the game with all items"
|
||||||
if (board.items == totalItems)
|
if (board_.items == total_items_)
|
||||||
{
|
{
|
||||||
cheevos->unlock(10);
|
cheevos_->unlock(10);
|
||||||
}
|
}
|
||||||
|
|
||||||
// "Complete the game without dying"
|
// "Complete the game without dying"
|
||||||
cheevos->unlock(11);
|
cheevos_->unlock(11);
|
||||||
|
|
||||||
// "Complete the game in under 30 minutes"
|
// "Complete the game in under 30 minutes"
|
||||||
if (scoreboard->getMinutes() < 30)
|
if (scoreboard_->getMinutes() < 30)
|
||||||
{
|
{
|
||||||
cheevos->unlock(12);
|
cheevos_->unlock(12);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -27,38 +27,38 @@ class Game
|
|||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
// Objetos y punteros
|
// Objetos y punteros
|
||||||
SDL_Renderer *renderer; // El renderizador de la ventana
|
Screen *screen_; // Objeto encargado de manejar el renderizador
|
||||||
SDL_Event *eventHandler; // Manejador de eventos
|
SDL_Renderer *renderer_; // El renderizador de la ventana
|
||||||
Screen *screen; // Objeto encargado de manejar el renderizador
|
SDL_Event *event_handler_; // Manejador de eventos
|
||||||
Room *room; // Objeto encargado de gestionar cada habitación del juego
|
Room *room_; // Objeto encargado de gestionar cada habitación del juego
|
||||||
Player *player; // Objeto con el jugador
|
Player *player_; // Objeto con el jugador
|
||||||
ItemTracker *itemTracker; // Lleva el control de los objetos recogidos
|
ItemTracker *item_tracker_; // Lleva el control de los objetos recogidos
|
||||||
RoomTracker *roomTracker; // Lleva el control de las habitaciones visitadas
|
RoomTracker *room_tracker_; // Lleva el control de las habitaciones visitadas
|
||||||
Asset *asset; // Objeto con la ruta a todos los ficheros de recursos
|
Asset *asset_; // Objeto con la ruta a todos los ficheros de recursos
|
||||||
Input *input; // Objeto pata gestionar la entrada
|
Input *input_; // Objeto pata gestionar la entrada
|
||||||
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
|
||||||
Cheevos *cheevos; // Objeto encargado de gestionar los logros del juego
|
Cheevos *cheevos_; // Objeto encargado de gestionar los logros del juego
|
||||||
Resource *resource; // Objeto con los recursos
|
Resource *resource_; // Objeto con los recursos
|
||||||
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
|
options_t *options_; // Puntero a las opciones del juego
|
||||||
Stats *stats; // Objeto encargado de gestionar las estadísticas
|
Stats *stats_; // Objeto encargado de gestionar las estadísticas
|
||||||
SDL_Texture *roomNameTexture; // Textura para escribir el nombre de la habitación
|
SDL_Texture *room_name_texture_; // Textura para escribir el nombre de la habitación
|
||||||
section_t *section; // Seccion actual dentro del juego
|
section_t *section_; // Seccion actual dentro del juego
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
JA_Music_t *music; // Musica que suena durante el juego
|
JA_Music_t *music_; // Musica que suena durante el juego
|
||||||
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
|
Uint32 ticks_; // Contador de ticks para ajustar la velocidad del programa
|
||||||
Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
|
Uint32 ticks_speed_; // Velocidad a la que se repiten los bucles del programa
|
||||||
std::string currentRoom; // Fichero de la habitación actual
|
std::string current_room_; // Fichero de la habitación actual
|
||||||
playerSpawn_t spawnPoint; // Lugar de la habitación donde aparece el jugador
|
playerSpawn_t spawn_point_; // Lugar de la habitación donde aparece el jugador
|
||||||
JA_Sound_t *deathSound; // Sonido a reproducir cuando muere el jugador
|
JA_Sound_t *death_sound_; // Sonido a reproducir cuando muere el jugador
|
||||||
board_t board; // Estructura con los datos del marcador
|
board_t board_; // Estructura con los datos del marcador
|
||||||
bool paused; // Indica si el juego se encuentra en pausa
|
bool paused_; // Indica si el juego se encuentra en pausa
|
||||||
bool blackScreen; // Indica si la pantalla está en negro. Se utiliza para la muerte del jugador
|
bool black_screen_; // Indica si la pantalla está en negro. Se utiliza para la muerte del jugador
|
||||||
int blackScreenCounter; // Contador para temporizar la pantalla en negro
|
int black_screen_counter_; // Contador para temporizar la pantalla en negro
|
||||||
int totalItems; // Cantidad total de items que hay en el mapeado del juego
|
int total_items_; // Cantidad total de items que hay en el mapeado del juego
|
||||||
SDL_Rect roomNameRect; // Rectangulo donde pintar la textura con el nombre de la habitación
|
SDL_Rect room_name_rect_; // Rectangulo donde pintar la textura con el nombre de la habitación
|
||||||
|
|
||||||
// Actualiza el juego, las variables, comprueba la entrada, etc.
|
// Actualiza el juego, las variables, comprueba la entrada, etc.
|
||||||
void update();
|
void update();
|
||||||
@@ -151,7 +151,7 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
Game(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options, Input *input, section_t *section, Debug *debug);
|
Game(Resource *resource, options_t *options, section_t *section, Debug *debug);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~Game();
|
~Game();
|
||||||
|
|||||||
@@ -13,14 +13,14 @@
|
|||||||
#include "texture.h" // Para Texture
|
#include "texture.h" // Para Texture
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
GameOver::GameOver(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, Input *input, options_t *options, section_t *section)
|
GameOver::GameOver(Resource *resource, options_t *options, section_t *section)
|
||||||
{
|
{
|
||||||
// Copia los punteros
|
// Copia los punteros
|
||||||
this->renderer = renderer;
|
this->screen = Screen::get();
|
||||||
this->screen = screen;
|
this->renderer = Screen::get()->getRenderer();
|
||||||
this->resource = resource;
|
this->resource = resource;
|
||||||
this->asset = asset;
|
this->asset = Asset::get();
|
||||||
this->input = input;
|
this->input = Input::get();
|
||||||
this->options = options;
|
this->options = options;
|
||||||
this->section = section;
|
this->section = section;
|
||||||
|
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
GameOver(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, Input *input, options_t *options, section_t *section);
|
GameOver(Resource *resource, options_t *options, section_t *section);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~GameOver();
|
~GameOver();
|
||||||
|
|||||||
@@ -13,9 +13,9 @@
|
|||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
LoadingScreen::LoadingScreen(Resource *resource, options_t *options, section_t *section)
|
LoadingScreen::LoadingScreen(Resource *resource, options_t *options, section_t *section)
|
||||||
: resource_(resource),
|
: screen_(Screen::get()),
|
||||||
screen_(Screen::get()),
|
|
||||||
renderer_(Screen::get()->getRenderer()),
|
renderer_(Screen::get()->getRenderer()),
|
||||||
|
resource_(resource),
|
||||||
asset_(Asset::get()),
|
asset_(Asset::get()),
|
||||||
input_(Input::get()),
|
input_(Input::get()),
|
||||||
options_(options),
|
options_(options),
|
||||||
|
|||||||
@@ -18,8 +18,8 @@ class LoadingScreen
|
|||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
// Objetos y punteros
|
// Objetos y punteros
|
||||||
SDL_Renderer *renderer_; // El renderizador de la ventana
|
|
||||||
Screen *screen_; // Objeto encargado de dibujar en pantalla
|
Screen *screen_; // Objeto encargado de dibujar en pantalla
|
||||||
|
SDL_Renderer *renderer_; // El renderizador de la ventana
|
||||||
Resource *resource_; // Objeto con los recursos
|
Resource *resource_; // Objeto con los recursos
|
||||||
Asset *asset_; // Objeto con los ficheros de recursos
|
Asset *asset_; // Objeto con los ficheros de recursos
|
||||||
Input *input_; // Objeto pata gestionar la entrada
|
Input *input_; // Objeto pata gestionar la entrada
|
||||||
|
|||||||
@@ -14,9 +14,9 @@ class Asset; // lines 11-11
|
|||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Logo::Logo(Resource *resource, options_t *options, section_t *section)
|
Logo::Logo(Resource *resource, options_t *options, section_t *section)
|
||||||
: resource_(resource),
|
: screen_(Screen::get()),
|
||||||
screen_(Screen::get()),
|
|
||||||
renderer_(Screen::get()->getRenderer()),
|
renderer_(Screen::get()->getRenderer()),
|
||||||
|
resource_(resource),
|
||||||
asset_(Asset::get()),
|
asset_(Asset::get()),
|
||||||
input_(Input::get()),
|
input_(Input::get()),
|
||||||
options_(options),
|
options_(options),
|
||||||
@@ -24,8 +24,8 @@ Logo::Logo(Resource *resource, options_t *options, section_t *section)
|
|||||||
{
|
{
|
||||||
// Reserva memoria para los punteros
|
// Reserva memoria para los punteros
|
||||||
event_handler_ = new SDL_Event();
|
event_handler_ = new SDL_Event();
|
||||||
jailgames_texture_ = resource->getTexture("jailgames.png");
|
jailgames_texture_ = resource_->getTexture("jailgames.png");
|
||||||
since_1998_texture_ = resource->getTexture("since_1998.png");
|
since_1998_texture_ = resource_->getTexture("since_1998.png");
|
||||||
since_1998_sprite_ = new Sprite((256 - since_1998_texture_->getWidth()) / 2, 83 + jailgames_texture_->getHeight() + 5, since_1998_texture_->getWidth(), since_1998_texture_->getHeight(), since_1998_texture_, renderer_);
|
since_1998_sprite_ = new Sprite((256 - since_1998_texture_->getWidth()) / 2, 83 + jailgames_texture_->getHeight() + 5, since_1998_texture_->getWidth(), since_1998_texture_->getHeight(), since_1998_texture_, renderer_);
|
||||||
since_1998_sprite_->setSpriteClip(0, 0, since_1998_texture_->getWidth(), since_1998_texture_->getHeight());
|
since_1998_sprite_->setSpriteClip(0, 0, since_1998_texture_->getWidth(), since_1998_texture_->getHeight());
|
||||||
since_1998_texture_->setColor(0, 0, 0);
|
since_1998_texture_->setColor(0, 0, 0);
|
||||||
|
|||||||
@@ -18,8 +18,8 @@ class Logo
|
|||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
// Objetos y punteros
|
// Objetos y punteros
|
||||||
SDL_Renderer *renderer_; // El renderizador de la ventana
|
|
||||||
Screen *screen_; // Objeto encargado de dibujar en pantalla
|
Screen *screen_; // Objeto encargado de dibujar en pantalla
|
||||||
|
SDL_Renderer *renderer_; // El renderizador de la ventana
|
||||||
Resource *resource_; // Objeto con los recursos
|
Resource *resource_; // Objeto con los recursos
|
||||||
Asset *asset_; // Objeto con los ficheros de recursos
|
Asset *asset_; // Objeto con los ficheros de recursos
|
||||||
Input *input_; // Objeto pata gestionar la entrada
|
Input *input_; // Objeto pata gestionar la entrada
|
||||||
|
|||||||
@@ -1,16 +1,38 @@
|
|||||||
#include "notify.h"
|
#include "notifier.h"
|
||||||
#include <SDL2/SDL_blendmode.h> // Para SDL_BLENDMODE_BLEND
|
#include <SDL2/SDL_blendmode.h> // Para SDL_BLENDMODE_BLEND
|
||||||
#include <string> // Para basic_string, string, char_traits
|
#include <string> // Para basic_string, string, char_traits
|
||||||
#include "jail_audio.h" // Para JA_DeleteSound, JA_LoadSound, JA_Pla...
|
#include "jail_audio.h" // Para JA_DeleteSound, JA_LoadSound, JA_Pla...
|
||||||
#include "sprite.h" // Para Sprite
|
#include "sprite.h" // Para Sprite
|
||||||
#include "text.h" // Para Text
|
#include "text.h" // Para Text
|
||||||
#include "texture.h" // Para Texture
|
#include "texture.h" // Para Texture
|
||||||
|
#include "screen.h"
|
||||||
|
|
||||||
|
// [SINGLETON]
|
||||||
|
Notifier *Notifier::notifier_ = nullptr;
|
||||||
|
|
||||||
|
// [SINGLETON] Crearemos el objeto con esta función estática
|
||||||
|
void Notifier::init(std::string iconFile, std::string bitmapFile, std::string textFile, std::string soundFile, options_t *options)
|
||||||
|
{
|
||||||
|
Notifier::notifier_ = new Notifier(iconFile, bitmapFile, textFile, soundFile, options);
|
||||||
|
}
|
||||||
|
|
||||||
|
// [SINGLETON] Destruiremos el objeto con esta función estática
|
||||||
|
void Notifier::destroy()
|
||||||
|
{
|
||||||
|
delete Notifier::notifier_;
|
||||||
|
}
|
||||||
|
|
||||||
|
// [SINGLETON] Con este método obtenemos el objeto y podemos trabajar con él
|
||||||
|
Notifier *Notifier::get()
|
||||||
|
{
|
||||||
|
return Notifier::notifier_;
|
||||||
|
}
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Notify::Notify(SDL_Renderer *renderer, std::string iconFile, std::string bitmapFile, std::string textFile, std::string soundFile, options_t *options)
|
Notifier::Notifier(std::string iconFile, std::string bitmapFile, std::string textFile, std::string soundFile, options_t *options)
|
||||||
{
|
{
|
||||||
// Inicializa variables
|
// Inicializa variables
|
||||||
this->renderer = renderer;
|
this->renderer = Screen::get()->getRenderer();
|
||||||
this->options = options;
|
this->options = options;
|
||||||
bgColor = options->notifications.color;
|
bgColor = options->notifications.color;
|
||||||
waitTime = 300;
|
waitTime = 300;
|
||||||
@@ -23,7 +45,7 @@ Notify::Notify(SDL_Renderer *renderer, std::string iconFile, std::string bitmapF
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
Notify::~Notify()
|
Notifier::~Notifier()
|
||||||
{
|
{
|
||||||
// Libera la memoria de los objetos
|
// Libera la memoria de los objetos
|
||||||
delete textTexture;
|
delete textTexture;
|
||||||
@@ -39,7 +61,7 @@ Notify::~Notify()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Dibuja las notificaciones por pantalla
|
// Dibuja las notificaciones por pantalla
|
||||||
void Notify::render()
|
void Notifier::render()
|
||||||
{
|
{
|
||||||
for (int i = (int)notifications.size() - 1; i >= 0; --i)
|
for (int i = (int)notifications.size() - 1; i >= 0; --i)
|
||||||
{
|
{
|
||||||
@@ -48,7 +70,7 @@ void Notify::render()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Actualiza el estado de las notificaiones
|
// Actualiza el estado de las notificaiones
|
||||||
void Notify::update()
|
void Notifier::update()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < (int)notifications.size(); ++i)
|
for (int i = 0; i < (int)notifications.size(); ++i)
|
||||||
{
|
{
|
||||||
@@ -136,7 +158,7 @@ void Notify::update()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Elimina las notificaciones finalizadas
|
// Elimina las notificaciones finalizadas
|
||||||
void Notify::clearFinishedNotifications()
|
void Notifier::clearFinishedNotifications()
|
||||||
{
|
{
|
||||||
for (int i = (int)notifications.size() - 1; i >= 0; --i)
|
for (int i = (int)notifications.size() - 1; i >= 0; --i)
|
||||||
{
|
{
|
||||||
@@ -150,7 +172,7 @@ void Notify::clearFinishedNotifications()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Muestra una notificación de texto por pantalla;
|
// Muestra una notificación de texto por pantalla;
|
||||||
void Notify::showText(std::string text1, std::string text2, int icon)
|
void Notifier::showText(std::string text1, std::string text2, int icon)
|
||||||
{
|
{
|
||||||
// Inicializa variables
|
// Inicializa variables
|
||||||
const int iconSize = 16;
|
const int iconSize = 16;
|
||||||
@@ -277,7 +299,7 @@ void Notify::showText(std::string text1, std::string text2, int icon)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Indica si hay notificaciones activas
|
// Indica si hay notificaciones activas
|
||||||
bool Notify::active()
|
bool Notifier::active()
|
||||||
{
|
{
|
||||||
if ((int)notifications.size() > 0)
|
if ((int)notifications.size() > 0)
|
||||||
{
|
{
|
||||||
@@ -10,9 +10,12 @@ class Text;
|
|||||||
class Texture;
|
class Texture;
|
||||||
struct JA_Sound_t;
|
struct JA_Sound_t;
|
||||||
|
|
||||||
class Notify
|
class Notifier
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
// [SINGLETON] Objeto notifier
|
||||||
|
static Notifier *notifier_;
|
||||||
|
|
||||||
enum notification_state_e
|
enum notification_state_e
|
||||||
{
|
{
|
||||||
ns_rising,
|
ns_rising,
|
||||||
@@ -63,19 +66,28 @@ private:
|
|||||||
// Elimina las notificaciones finalizadas
|
// Elimina las notificaciones finalizadas
|
||||||
void clearFinishedNotifications();
|
void clearFinishedNotifications();
|
||||||
|
|
||||||
|
// Constructor
|
||||||
|
Notifier(std::string iconFile, std::string bitmapFile, std::string textFile, std::string soundFile, options_t *options);
|
||||||
|
|
||||||
|
// Destructor
|
||||||
|
~Notifier();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
// [SINGLETON] Crearemos el objeto con esta función estática
|
||||||
|
static void init(std::string iconFile, std::string bitmapFile, std::string textFile, std::string soundFile, options_t *options);
|
||||||
|
|
||||||
|
// [SINGLETON] Destruiremos el objeto con esta función estática
|
||||||
|
static void destroy();
|
||||||
|
|
||||||
|
// [SINGLETON] Con este método obtenemos el objeto y podemos trabajar con él
|
||||||
|
static Notifier *get();
|
||||||
|
|
||||||
// Dibuja las notificaciones por pantalla
|
// Dibuja las notificaciones por pantalla
|
||||||
void render();
|
void render();
|
||||||
|
|
||||||
// Actualiza el estado de las notificaiones
|
// Actualiza el estado de las notificaiones
|
||||||
void update();
|
void update();
|
||||||
|
|
||||||
// Constructor
|
|
||||||
Notify(SDL_Renderer *renderer, std::string iconFile, std::string bitmapFile, std::string textFile, std::string soundFile, options_t *options);
|
|
||||||
|
|
||||||
// Destructor
|
|
||||||
~Notify();
|
|
||||||
|
|
||||||
// Muestra una notificación de texto por pantalla;
|
// Muestra una notificación de texto por pantalla;
|
||||||
void showText(std::string text1 = "", std::string text2 = "", int icon = -1);
|
void showText(std::string text1 = "", std::string text2 = "", int icon = -1);
|
||||||
|
|
||||||
@@ -10,7 +10,7 @@
|
|||||||
#include <string> // Para basic_string, char_traits, string
|
#include <string> // Para basic_string, char_traits, string
|
||||||
#include "asset.h" // Para Asset
|
#include "asset.h" // Para Asset
|
||||||
#include "jail_shader.h" // Para init, render
|
#include "jail_shader.h" // Para init, render
|
||||||
#include "notify.h" // Para Notify
|
#include "notifier.h" // Para Notify
|
||||||
|
|
||||||
// [SINGLETON]
|
// [SINGLETON]
|
||||||
Screen *Screen::screen_ = nullptr;
|
Screen *Screen::screen_ = nullptr;
|
||||||
@@ -36,12 +36,8 @@ Screen *Screen::get()
|
|||||||
// Constructor
|
// Constructor
|
||||||
Screen::Screen(SDL_Window *window, SDL_Renderer *renderer)
|
Screen::Screen(SDL_Window *window, SDL_Renderer *renderer)
|
||||||
: window_(window),
|
: window_(window),
|
||||||
renderer_(renderer),
|
renderer_(renderer)
|
||||||
asset_(Asset::get())
|
|
||||||
{
|
{
|
||||||
// Crea los objetos
|
|
||||||
notify_ = new Notify(renderer, asset_->get("notify.png"), asset_->get("smb2.png"), asset_->get("smb2.txt"), asset_->get("notify.wav"), options_);
|
|
||||||
|
|
||||||
game_canvas_width_ = options_->gameWidth;
|
game_canvas_width_ = options_->gameWidth;
|
||||||
game_canvas_height_ = options_->gameHeight;
|
game_canvas_height_ = options_->gameHeight;
|
||||||
notification_logical_width_ = game_canvas_width_;
|
notification_logical_width_ = game_canvas_width_;
|
||||||
@@ -77,9 +73,6 @@ Screen::Screen(SDL_Window *window, SDL_Renderer *renderer)
|
|||||||
// Establece el modo de video
|
// Establece el modo de video
|
||||||
setVideoMode(options_->videoMode);
|
setVideoMode(options_->videoMode);
|
||||||
|
|
||||||
// Inicializa variables
|
|
||||||
notify_active_ = false;
|
|
||||||
|
|
||||||
// Muestra la ventana
|
// Muestra la ventana
|
||||||
SDL_ShowWindow(window);
|
SDL_ShowWindow(window);
|
||||||
}
|
}
|
||||||
@@ -87,7 +80,6 @@ Screen::Screen(SDL_Window *window, SDL_Renderer *renderer)
|
|||||||
// Destructor
|
// Destructor
|
||||||
Screen::~Screen()
|
Screen::~Screen()
|
||||||
{
|
{
|
||||||
delete notify_;
|
|
||||||
SDL_DestroyTexture(game_canvas_);
|
SDL_DestroyTexture(game_canvas_);
|
||||||
SDL_DestroyTexture(border_canvas_);
|
SDL_DestroyTexture(border_canvas_);
|
||||||
}
|
}
|
||||||
@@ -217,14 +209,11 @@ void Screen::setVideoMode(int videoMode)
|
|||||||
options_->screen.windowWidth = window_width_;
|
options_->screen.windowWidth = window_width_;
|
||||||
options_->screen.windowHeight = window_height_;
|
options_->screen.windowHeight = window_height_;
|
||||||
|
|
||||||
// Establece el tamaño de las notificaciones
|
|
||||||
setNotificationSize();
|
|
||||||
|
|
||||||
// Reinicia los shaders
|
// Reinicia los shaders
|
||||||
if (options_->shaders)
|
if (options_->shaders)
|
||||||
{
|
{
|
||||||
const std::string glsl_file = options_->screen.windowHeight == 192 ? "crtpi_192.glsl" : "crtpi_240.glsl";
|
const std::string glsl_file = options_->screen.windowHeight == 192 ? "crtpi_192.glsl" : "crtpi_240.glsl";
|
||||||
std::ifstream f(asset_->get(glsl_file).c_str());
|
std::ifstream f(Asset::get()->get(glsl_file).c_str());
|
||||||
std::string source((std::istreambuf_iterator<char>(f)), std::istreambuf_iterator<char>());
|
std::string source((std::istreambuf_iterator<char>(f)), std::istreambuf_iterator<char>());
|
||||||
|
|
||||||
if (options_->borderEnabled)
|
if (options_->borderEnabled)
|
||||||
@@ -448,46 +437,21 @@ void Screen::renderFX()
|
|||||||
// Actualiza el notificador
|
// Actualiza el notificador
|
||||||
void Screen::updateNotifier()
|
void Screen::updateNotifier()
|
||||||
{
|
{
|
||||||
notify_->update();
|
Notifier::get()->update();
|
||||||
notify_active_ = notify_->active();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Muestra una notificación de texto por pantalla;
|
// Muestra una notificación de texto por pantalla;
|
||||||
void Screen::showNotification(std::string text1, std::string text2, int icon)
|
void Screen::showNotification(std::string text1, std::string text2, int icon)
|
||||||
{
|
{
|
||||||
notify_->showText(text1, text2, icon);
|
Notifier::get()->showText(text1, text2, icon);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dibuja las notificaciones
|
// Dibuja las notificaciones
|
||||||
void Screen::renderNotifications()
|
void Screen::renderNotifications()
|
||||||
{
|
{
|
||||||
if (notify_active_)
|
if (Notifier::get()->active())
|
||||||
{
|
{
|
||||||
notify_->render();
|
Notifier::get()->render();
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Establece el tamaño de las notificaciones
|
|
||||||
void Screen::setNotificationSize()
|
|
||||||
{
|
|
||||||
if (options_->videoMode == 0)
|
|
||||||
{
|
|
||||||
if (options_->windowSize == 3)
|
|
||||||
{
|
|
||||||
notification_logical_width_ = (window_width_ * 3) / 2;
|
|
||||||
notification_logical_height_ = (window_height_ * 3) / 2;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
notification_logical_width_ = window_width_ * 2;
|
|
||||||
notification_logical_height_ = window_height_ * 2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (options_->videoMode == SDL_WINDOW_FULLSCREEN_DESKTOP)
|
|
||||||
{
|
|
||||||
notification_logical_width_ = window_width_ / 3;
|
|
||||||
notification_logical_height_ = window_height_ / 3;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
#include <vector> // Para vector
|
#include <vector> // Para vector
|
||||||
#include "utils.h" // Para color_t
|
#include "utils.h" // Para color_t
|
||||||
class Asset;
|
class Asset;
|
||||||
class Notify;
|
class Notifier;
|
||||||
|
|
||||||
constexpr int FILTER_NEAREST = 0;
|
constexpr int FILTER_NEAREST = 0;
|
||||||
constexpr int FILTER_LINEAR = 1;
|
constexpr int FILTER_LINEAR = 1;
|
||||||
@@ -22,11 +22,9 @@ private:
|
|||||||
// Objetos y punteros
|
// Objetos y punteros
|
||||||
SDL_Window *window_; // Ventana de la aplicación
|
SDL_Window *window_; // Ventana de la aplicación
|
||||||
SDL_Renderer *renderer_; // El renderizador de la ventana
|
SDL_Renderer *renderer_; // El renderizador de la ventana
|
||||||
Asset *asset_; // Objeto con el listado de recursos
|
|
||||||
SDL_Texture *game_canvas_; // Textura donde se dibuja el juego
|
SDL_Texture *game_canvas_; // Textura donde se dibuja el juego
|
||||||
SDL_Texture *border_canvas_; // Textura donde se dibuja el borde del juego
|
SDL_Texture *border_canvas_; // Textura donde se dibuja el borde del juego
|
||||||
options_t *options_; // Variable con todas las opciones del programa
|
options_t *options_; // Variable con todas las opciones del programa
|
||||||
Notify *notify_; // Dibuja notificaciones por pantalla
|
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
int window_width_; // Ancho de la pantalla o ventana
|
int window_width_; // Ancho de la pantalla o ventana
|
||||||
@@ -35,7 +33,6 @@ private:
|
|||||||
int game_canvas_height_; // Resolución interna del juego. Es el alto de la textura donde se dibuja el juego
|
int game_canvas_height_; // Resolución interna del juego. Es el alto de la textura donde se dibuja el juego
|
||||||
SDL_Rect dest_; // Coordenadas donde se va a dibujar la textura del juego sobre la pantalla o ventana
|
SDL_Rect dest_; // Coordenadas donde se va a dibujar la textura del juego sobre la pantalla o ventana
|
||||||
color_t border_color_; // Color del borde añadido a la textura de juego para rellenar la pantalla
|
color_t border_color_; // Color del borde añadido a la textura de juego para rellenar la pantalla
|
||||||
bool notify_active_; // Indica si hay notificaciones activas
|
|
||||||
int notification_logical_width_; // Ancho lógico de las notificaciones en relación al tamaño de pantalla
|
int notification_logical_width_; // Ancho lógico de las notificaciones en relación al tamaño de pantalla
|
||||||
int notification_logical_height_; // Alto lógico de las notificaciones en relación al tamaño de pantalla
|
int notification_logical_height_; // Alto lógico de las notificaciones en relación al tamaño de pantalla
|
||||||
|
|
||||||
@@ -69,9 +66,6 @@ private:
|
|||||||
// Dibuja las notificaciones
|
// Dibuja las notificaciones
|
||||||
void renderNotifications();
|
void renderNotifications();
|
||||||
|
|
||||||
// Establece el tamaño de las notificaciones
|
|
||||||
void setNotificationSize();
|
|
||||||
|
|
||||||
// Copia el gameCanvas en el borderCanvas
|
// Copia el gameCanvas en el borderCanvas
|
||||||
void gameCanvasToBorderCanvas();
|
void gameCanvasToBorderCanvas();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user