1900 lines
57 KiB
C++
1900 lines
57 KiB
C++
#include "jail_engine/jscore.h"
|
||
#include "jail_engine/utils.h"
|
||
#include "director.h"
|
||
#include <errno.h>
|
||
#include <iostream>
|
||
#include <string>
|
||
#include <sys/stat.h>
|
||
#include <unistd.h>
|
||
|
||
#ifndef _WIN32
|
||
#include <pwd.h>
|
||
#endif
|
||
|
||
// Constructor
|
||
Director::Director(int argc, char *argv[])
|
||
{
|
||
section = new section_t();
|
||
section->name = SECTION_PROG_LOGO;
|
||
section->subsection = SUBSECTION_LOGO_TO_INTRO;
|
||
|
||
#ifdef DEBUG
|
||
section->name = SECTION_PROG_TITLE;
|
||
#endif
|
||
|
||
// Crea e inicializa las opciones del programa
|
||
initOptions();
|
||
|
||
// Comprueba los parametros del programa
|
||
checkProgramArguments(argc, argv);
|
||
|
||
// Crea la carpeta del sistema donde guardar datos
|
||
createSystemFolder("jailgames");
|
||
#ifndef DEBUG
|
||
createSystemFolder("jailgames/jaildoctors_dilemma");
|
||
#else
|
||
createSystemFolder("jailgames/jaildoctors_dilemma_debug");
|
||
#endif
|
||
|
||
// Crea el objeto que controla los ficheros de recursos
|
||
asset = new Asset(executablePath);
|
||
asset->setVerbose(options->console);
|
||
|
||
// Si falta algún fichero no inicia el programa
|
||
if (!setFileList())
|
||
{
|
||
exit(EXIT_FAILURE);
|
||
}
|
||
|
||
// Inicializa variables desde el fichero de configuración
|
||
loadConfig();
|
||
|
||
// Inicializa SDL
|
||
initSDL();
|
||
|
||
// Inicializa JailAudio
|
||
initJailAudio();
|
||
|
||
// Crea los objetos
|
||
resource = new Resource(renderer, asset, options);
|
||
input = new Input(asset->get("gamecontrollerdb.txt"));
|
||
initInput();
|
||
screen = new Screen(window, renderer, asset, options);
|
||
screen->setBorderColor(borderColor);
|
||
debug = new Debug(renderer, screen, asset);
|
||
music = JA_LoadMusic(asset->get("title.ogg").c_str());
|
||
online = new Online(options);
|
||
}
|
||
|
||
Director::~Director()
|
||
{
|
||
// Guarda las opciones de configuración
|
||
saveConfig();
|
||
|
||
// Libera la memoria
|
||
delete section;
|
||
delete options;
|
||
delete asset;
|
||
delete input;
|
||
delete screen;
|
||
delete debug;
|
||
delete resource;
|
||
delete online;
|
||
JA_DeleteMusic(music);
|
||
|
||
SDL_DestroyRenderer(renderer);
|
||
SDL_DestroyWindow(window);
|
||
SDL_Quit();
|
||
}
|
||
|
||
// Inicializa los servicios online
|
||
void Director::initOnline()
|
||
{
|
||
if (options->online.jailerID == "")
|
||
{ // Jailer ID no definido
|
||
|
||
options->online.enabled = false;
|
||
}
|
||
else
|
||
{ // Jailer ID iniciado
|
||
|
||
if (options->online.enabled)
|
||
{ // Establece el servidor y el puerto
|
||
jscore::init(options->online.server, options->online.port);
|
||
|
||
const std::string caption = options->online.jailerID + " IS LOGGED IN";
|
||
screen->showNotification(caption);
|
||
if (options->console)
|
||
{
|
||
std::cout << caption << std::endl;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
// Crea e inicializa las opciones del programa
|
||
void Director::initOptions()
|
||
{
|
||
// Crea el puntero a la estructura de opciones
|
||
options = new options_t;
|
||
|
||
// Version del archivo de configuración
|
||
options->configVersion = "v1.06.1";
|
||
|
||
// Opciones de control
|
||
options->keys = ctrl_cursor;
|
||
|
||
// Opciones de video
|
||
options->gameWidth = GAMECANVAS_WIDTH;
|
||
options->gameHeight = GAMECANVAS_HEIGHT;
|
||
options->videoMode = 0;
|
||
options->windowSize = 3;
|
||
options->filter = FILTER_NEAREST;
|
||
options->vSync = true;
|
||
options->integerScale = true;
|
||
options->keepAspect = true;
|
||
options->borderEnabled = true;
|
||
options->borderWidth = 32;
|
||
options->borderHeight = 24;
|
||
options->palette = p_zxspectrum;
|
||
|
||
#ifdef GAME_CONSOLE
|
||
options->windowSize = 2;
|
||
#endif
|
||
|
||
// Estos valores no se guardan en el fichero de configuraci´ón
|
||
options->console = false;
|
||
#ifdef DEBUG
|
||
options->console = true;
|
||
#endif
|
||
options->cheat.infiniteLives = false;
|
||
options->cheat.invincible = false;
|
||
options->cheat.jailEnabled = false;
|
||
options->cheat.altSkin = false;
|
||
options->stats.rooms = 0;
|
||
options->stats.items = 0;
|
||
|
||
// Opciones online
|
||
options->online.enabled = true;
|
||
options->online.sessionEnabled = false;
|
||
options->online.server = "jaildoctor.duckdns.org";
|
||
options->online.port = 9911;
|
||
#ifdef DEBUG
|
||
options->online.gameID = "jaildoctors_dilemma_debug";
|
||
#else
|
||
options->online.gameID = "jaildoctors_dilemma";
|
||
#endif
|
||
options->online.jailerID = "";
|
||
|
||
// Opciones de las notificaciones
|
||
options->notifications.posV = pos_top;
|
||
options->notifications.posH = pos_left;
|
||
options->notifications.sound = true;
|
||
options->notifications.color = {48, 48, 48};
|
||
}
|
||
|
||
// Comprueba los parametros del programa
|
||
void Director::checkProgramArguments(int argc, char *argv[])
|
||
{
|
||
// Establece la ruta del programa
|
||
executablePath = argv[0];
|
||
|
||
// Comprueba el resto de parametros
|
||
for (int i = 1; i < argc; ++i)
|
||
{
|
||
if (strcmp(argv[i], "--console") == 0)
|
||
{
|
||
options->console = true;
|
||
}
|
||
|
||
else if (strcmp(argv[i], "--infiniteLives") == 0)
|
||
{
|
||
options->cheat.infiniteLives = true;
|
||
}
|
||
|
||
else if (strcmp(argv[i], "--invincible") == 0)
|
||
{
|
||
options->cheat.invincible = true;
|
||
}
|
||
|
||
else if (strcmp(argv[i], "--jailEnabled") == 0)
|
||
{
|
||
options->cheat.jailEnabled = true;
|
||
}
|
||
|
||
else if (strcmp(argv[i], "--altSkin") == 0)
|
||
{
|
||
options->cheat.altSkin = true;
|
||
}
|
||
}
|
||
}
|
||
|
||
// Carga el fichero de configuración
|
||
bool Director::loadConfig()
|
||
{
|
||
// Indicador de éxito en la carga
|
||
bool success = true;
|
||
|
||
// Versión actual del fichero
|
||
const std::string configVersion = options->configVersion;
|
||
options->configVersion = "";
|
||
|
||
// Variables para manejar el fichero
|
||
std::string line;
|
||
std::ifstream file(asset->get("config.txt"));
|
||
|
||
// Si el fichero se puede abrir
|
||
if (file.good())
|
||
{
|
||
// Procesa el fichero linea a linea
|
||
if (options->console)
|
||
{
|
||
std::cout << "Reading file config.txt\n";
|
||
}
|
||
while (std::getline(file, line))
|
||
{
|
||
// Comprueba que la linea no sea un comentario
|
||
if (line.substr(0, 1) != "#")
|
||
{
|
||
// Encuentra la posición del caracter '='
|
||
int pos = line.find("=");
|
||
// Procesa las dos subcadenas
|
||
if (!setOptions(options, line.substr(0, pos), line.substr(pos + 1, line.length())))
|
||
{
|
||
if (options->console)
|
||
{
|
||
std::cout << "Warning: file config.txt\n";
|
||
std::cout << "unknown parameter " << line.substr(0, pos).c_str() << std::endl;
|
||
}
|
||
success = false;
|
||
}
|
||
}
|
||
}
|
||
|
||
// Cierra el fichero
|
||
if (options->console)
|
||
{
|
||
std::cout << "Closing file config.txt\n\n";
|
||
}
|
||
file.close();
|
||
}
|
||
|
||
// El fichero no existe
|
||
else
|
||
{ // Crea el fichero con los valores por defecto
|
||
saveConfig();
|
||
}
|
||
|
||
// Si la versión de fichero no coincide, crea un fichero nuevo con los valores por defecto
|
||
if (configVersion != options->configVersion)
|
||
{
|
||
initOptions();
|
||
saveConfig();
|
||
}
|
||
|
||
// Normaliza los valores
|
||
const bool a = options->videoMode == 0;
|
||
const bool b = options->videoMode == SDL_WINDOW_FULLSCREEN;
|
||
const bool c = options->videoMode == SDL_WINDOW_FULLSCREEN_DESKTOP;
|
||
if (!(a || b || c))
|
||
{
|
||
options->videoMode = 0;
|
||
}
|
||
|
||
if (options->windowSize < 1 || options->windowSize > 4)
|
||
{
|
||
options->windowSize = 3;
|
||
}
|
||
|
||
// Aplica opciones
|
||
// if (options->borderEnabled)
|
||
//{
|
||
// const int incWidth = GAMECANVAS_WIDTH * options->borderSize;
|
||
// const int incHeight = GAMECANVAS_HEIGHT * options->borderSize;
|
||
// options->gameWidth = GAMECANVAS_WIDTH + incWidth;
|
||
// options->gameHeight = GAMECANVAS_HEIGHT + incHeight;
|
||
//}
|
||
// else
|
||
//{
|
||
// options->gameWidth = GAMECANVAS_WIDTH;
|
||
// options->gameHeight = GAMECANVAS_HEIGHT;
|
||
//}
|
||
|
||
return success;
|
||
}
|
||
|
||
// Guarda el fichero de configuración
|
||
bool Director::saveConfig()
|
||
{
|
||
bool success = true;
|
||
|
||
// Crea y abre el fichero de texto
|
||
std::ofstream file(asset->get("config.txt"));
|
||
|
||
if (file.good())
|
||
{
|
||
if (options->console)
|
||
{
|
||
std::cout << asset->get("config.txt") << " open for writing" << std::endl;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if (options->console)
|
||
{
|
||
std::cout << asset->get("config.txt") << " can't be opened" << std::endl;
|
||
}
|
||
}
|
||
|
||
// Escribe en el fichero
|
||
file << "## VERSION\n";
|
||
file << "configVersion=" + options->configVersion + "\n";
|
||
|
||
file << "\n## CONTROL OPTIONS\n";
|
||
file << "## keys = CURSOR | OPQA | WASD\n";
|
||
if (options->keys == ctrl_cursor)
|
||
{
|
||
file << "keys=CURSOR\n";
|
||
}
|
||
else if (options->keys == ctrl_opqa)
|
||
{
|
||
file << "keys=OPQA\n";
|
||
}
|
||
else if (options->keys == ctrl_wasd)
|
||
{
|
||
file << "keys=WASD\n";
|
||
}
|
||
|
||
file << "\n## VISUAL OPTIONS\n";
|
||
if (options->videoMode == 0)
|
||
{
|
||
file << "videoMode=0\n";
|
||
}
|
||
|
||
else if (options->videoMode == SDL_WINDOW_FULLSCREEN)
|
||
{
|
||
file << "videoMode=SDL_WINDOW_FULLSCREEN\n";
|
||
}
|
||
|
||
else if (options->videoMode == SDL_WINDOW_FULLSCREEN_DESKTOP)
|
||
{
|
||
file << "videoMode=SDL_WINDOW_FULLSCREEN_DESKTOP\n";
|
||
}
|
||
|
||
file << "windowSize=" + std::to_string(options->windowSize) + "\n";
|
||
|
||
if (options->filter == FILTER_NEAREST)
|
||
{
|
||
file << "filter=FILTER_NEAREST\n";
|
||
}
|
||
else
|
||
{
|
||
file << "filter=FILTER_LINEAL\n";
|
||
}
|
||
|
||
file << "vSync=" + boolToString(options->vSync) + "\n";
|
||
file << "integerScale=" + boolToString(options->integerScale) + "\n";
|
||
file << "keepAspect=" + boolToString(options->keepAspect) + "\n";
|
||
file << "borderEnabled=" + boolToString(options->borderEnabled) + "\n";
|
||
file << "borderWidth=" + std::to_string(options->borderWidth) + "\n";
|
||
file << "borderHeight=" + std::to_string(options->borderHeight) + "\n";
|
||
file << "palette=" + std::to_string(options->palette) + "\n";
|
||
|
||
file << "\n## ONLINE OPTIONS\n";
|
||
file << "enabled=" + boolToString(options->online.enabled) + "\n";
|
||
file << "server=" + options->online.server + "\n";
|
||
file << "port=" + std::to_string(options->online.port) + "\n";
|
||
file << "jailerID=" + options->online.jailerID + "\n";
|
||
|
||
file << "\n## NOTIFICATION OPTIONS\n";
|
||
file << "## notifications.posV = pos_top | pos_bottom\n";
|
||
if (options->notifications.posV == pos_top)
|
||
{
|
||
file << "notifications.posV=pos_top\n";
|
||
}
|
||
else
|
||
{
|
||
file << "notifications.posV=pos_bottom\n";
|
||
}
|
||
|
||
file << "## notifications.posH = pos_left | pos_middle | pos_right\n";
|
||
if (options->notifications.posH == pos_left)
|
||
{
|
||
file << "notifications.posH=pos_left\n";
|
||
}
|
||
else if (options->notifications.posH == pos_middle)
|
||
{
|
||
file << "notifications.posH=pos_middle\n";
|
||
}
|
||
else
|
||
{
|
||
file << "notifications.posH=pos_right\n";
|
||
}
|
||
|
||
file << "notifications.sound=" + boolToString(options->notifications.sound) + "\n";
|
||
|
||
// Cierra el fichero
|
||
file.close();
|
||
|
||
return success;
|
||
}
|
||
|
||
// Crea la carpeta del sistema donde guardar datos
|
||
void Director::createSystemFolder(std::string folder)
|
||
{
|
||
#ifdef _WIN32
|
||
systemFolder = std::string(getenv("APPDATA")) + "/" + folder;
|
||
#elif __APPLE__
|
||
struct passwd *pw = getpwuid(getuid());
|
||
const char *homedir = pw->pw_dir;
|
||
systemFolder = std::string(homedir) + "/Library/Application Support" + "/" + folder;
|
||
#elif __linux__
|
||
struct passwd *pw = getpwuid(getuid());
|
||
const char *homedir = pw->pw_dir;
|
||
systemFolder = std::string(homedir) + "/." + folder;
|
||
#endif
|
||
|
||
struct stat st = {0};
|
||
if (stat(systemFolder.c_str(), &st) == -1)
|
||
{
|
||
errno = 0;
|
||
#ifdef _WIN32
|
||
int ret = mkdir(systemFolder.c_str());
|
||
#else
|
||
int ret = mkdir(systemFolder.c_str(), S_IRWXU);
|
||
#endif
|
||
|
||
if (ret == -1)
|
||
{
|
||
switch (errno)
|
||
{
|
||
case EACCES:
|
||
printf("the parent directory does not allow write");
|
||
exit(EXIT_FAILURE);
|
||
|
||
case EEXIST:
|
||
printf("pathname already exists");
|
||
exit(EXIT_FAILURE);
|
||
|
||
case ENAMETOOLONG:
|
||
printf("pathname is too long");
|
||
exit(EXIT_FAILURE);
|
||
|
||
default:
|
||
perror("mkdir");
|
||
exit(EXIT_FAILURE);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
// Carga los recursos
|
||
void Director::loadResources(section_t *section)
|
||
{
|
||
if (options->console)
|
||
{
|
||
std::cout << "** LOAD RESOURCES" << std::endl;
|
||
}
|
||
|
||
if (section->name == SECTION_PROG_LOGO)
|
||
{
|
||
std::vector<std::string> textureList;
|
||
textureList.push_back("jailgames.png");
|
||
textureList.push_back("since_1998.png");
|
||
|
||
resource->loadTextures(textureList);
|
||
}
|
||
|
||
else if (section->name == SECTION_PROG_INTRO)
|
||
{
|
||
std::vector<std::string> textureList;
|
||
textureList.push_back("loading_screen_bn.png");
|
||
textureList.push_back("loading_screen_color.png");
|
||
textureList.push_back("loading_screen_bn_zxarne.png");
|
||
textureList.push_back("loading_screen_color_zxarne.png");
|
||
|
||
resource->loadTextures(textureList);
|
||
}
|
||
|
||
else if (section->name == SECTION_PROG_TITLE)
|
||
{
|
||
std::vector<std::string> textureList;
|
||
textureList.push_back("loading_screen_color.png");
|
||
textureList.push_back("loading_screen_color_zxarne.png");
|
||
textureList.push_back("smb2.png");
|
||
textureList.push_back("subatomic.png");
|
||
textureList.push_back("notify.png");
|
||
|
||
resource->loadTextures(textureList);
|
||
|
||
// Offsets
|
||
std::vector<std::string> offsetsList;
|
||
offsetsList.push_back("smb2.txt");
|
||
offsetsList.push_back("subatomic.txt");
|
||
|
||
resource->loadOffsets(offsetsList);
|
||
}
|
||
|
||
else if (section->name == SECTION_PROG_CREDITS)
|
||
{
|
||
// Texturas
|
||
std::vector<std::string> textureList;
|
||
textureList.push_back("shine.png");
|
||
textureList.push_back("smb2.png");
|
||
|
||
resource->loadTextures(textureList);
|
||
|
||
// Animaciones
|
||
std::vector<std::string> animationList;
|
||
animationList.push_back("shine.ani");
|
||
|
||
resource->loadAnimations(animationList);
|
||
|
||
// Offsets
|
||
std::vector<std::string> offsetsList;
|
||
offsetsList.push_back("smb2.txt");
|
||
|
||
resource->loadOffsets(offsetsList);
|
||
}
|
||
|
||
else if (section->name == SECTION_PROG_ENDING)
|
||
{
|
||
// Texturas
|
||
std::vector<std::string> textureList;
|
||
textureList.push_back("ending1.png");
|
||
textureList.push_back("ending1_zxarne.png");
|
||
textureList.push_back("ending2.png");
|
||
textureList.push_back("ending2_zxarne.png");
|
||
textureList.push_back("ending3.png");
|
||
textureList.push_back("ending3_zxarne.png");
|
||
textureList.push_back("ending4.png");
|
||
textureList.push_back("ending4_zxarne.png");
|
||
textureList.push_back("ending5.png");
|
||
textureList.push_back("ending5_zxarne.png");
|
||
textureList.push_back("smb2.png");
|
||
|
||
resource->loadTextures(textureList);
|
||
|
||
// Offsets
|
||
std::vector<std::string> offsetsList;
|
||
offsetsList.push_back("smb2.txt");
|
||
|
||
resource->loadOffsets(offsetsList);
|
||
}
|
||
|
||
else if (section->name == SECTION_PROG_ENDING2)
|
||
{
|
||
// Texturas
|
||
std::vector<std::string> textureList;
|
||
|
||
// Texto
|
||
textureList.push_back("smb2.png");
|
||
|
||
// Enemigos
|
||
textureList.push_back("abad.png");
|
||
textureList.push_back("abad_bell.png");
|
||
textureList.push_back("amstrad_cs.png");
|
||
textureList.push_back("flying_arounder.png");
|
||
textureList.push_back("stopped_arounder.png");
|
||
textureList.push_back("walking_arounder.png");
|
||
textureList.push_back("arounders_door.png");
|
||
textureList.push_back("arounders_machine.png");
|
||
textureList.push_back("bat.png");
|
||
textureList.push_back("batman_bell.png");
|
||
textureList.push_back("batman_fire.png");
|
||
textureList.push_back("batman.png");
|
||
textureList.push_back("bell.png");
|
||
textureList.push_back("bin.png");
|
||
textureList.push_back("bird.png");
|
||
textureList.push_back("breakout.png");
|
||
textureList.push_back("bry.png");
|
||
textureList.push_back("chip.png");
|
||
textureList.push_back("code.png");
|
||
textureList.push_back("congo.png");
|
||
textureList.push_back("crosshair.png");
|
||
textureList.push_back("demon.png");
|
||
textureList.push_back("heavy.png");
|
||
textureList.push_back("dimallas.png");
|
||
textureList.push_back("floppy.png");
|
||
textureList.push_back("dong.png");
|
||
textureList.push_back("guitar.png");
|
||
textureList.push_back("jailbattle_alien.png");
|
||
textureList.push_back("jailbattle_human.png");
|
||
textureList.push_back("jailer_#1.png");
|
||
textureList.push_back("jailer_#2.png");
|
||
textureList.push_back("jailer_#3.png");
|
||
textureList.push_back("jeannine.png");
|
||
textureList.push_back("lamp.png");
|
||
textureList.push_back("lord_abad.png");
|
||
textureList.push_back("robot.png");
|
||
textureList.push_back("matatunos.png");
|
||
textureList.push_back("mummy.png");
|
||
textureList.push_back("paco.png");
|
||
textureList.push_back("elsa.png");
|
||
textureList.push_back("qvoid.png");
|
||
textureList.push_back("sam.png");
|
||
textureList.push_back("sigmasua.png");
|
||
textureList.push_back("spider.png");
|
||
textureList.push_back("spark.png");
|
||
textureList.push_back("tree_thing.png");
|
||
textureList.push_back("tuno.png");
|
||
textureList.push_back("tv_panel.png");
|
||
textureList.push_back("tv.png");
|
||
textureList.push_back("shock.png");
|
||
textureList.push_back("upv_student.png");
|
||
textureList.push_back("wave.png");
|
||
textureList.push_back("z80.png");
|
||
|
||
// Player
|
||
textureList.push_back("player.png");
|
||
|
||
resource->loadTextures(textureList);
|
||
|
||
// Animaciones
|
||
std::vector<std::string> animationList;
|
||
|
||
// Enemigos
|
||
animationList.push_back("abad.ani");
|
||
animationList.push_back("abad_bell.ani");
|
||
animationList.push_back("amstrad_cs.ani");
|
||
animationList.push_back("flying_arounder.ani");
|
||
animationList.push_back("stopped_arounder.ani");
|
||
animationList.push_back("walking_arounder.ani");
|
||
animationList.push_back("arounders_door.ani");
|
||
animationList.push_back("arounders_machine.ani");
|
||
animationList.push_back("bat.ani");
|
||
animationList.push_back("batman_bell.ani");
|
||
animationList.push_back("batman_fire.ani");
|
||
animationList.push_back("batman.ani");
|
||
animationList.push_back("bell.ani");
|
||
animationList.push_back("bin.ani");
|
||
animationList.push_back("bird.ani");
|
||
animationList.push_back("breakout.ani");
|
||
animationList.push_back("bry.ani");
|
||
animationList.push_back("chip.ani");
|
||
animationList.push_back("code.ani");
|
||
animationList.push_back("congo.ani");
|
||
animationList.push_back("crosshair.ani");
|
||
animationList.push_back("demon.ani");
|
||
animationList.push_back("heavy.ani");
|
||
animationList.push_back("dimallas.ani");
|
||
animationList.push_back("floppy.ani");
|
||
animationList.push_back("dong.ani");
|
||
animationList.push_back("guitar.ani");
|
||
animationList.push_back("jailbattle_alien.ani");
|
||
animationList.push_back("jailbattle_human.ani");
|
||
animationList.push_back("jailer_#1.ani");
|
||
animationList.push_back("jailer_#2.ani");
|
||
animationList.push_back("jailer_#3.ani");
|
||
animationList.push_back("jeannine.ani");
|
||
animationList.push_back("lamp.ani");
|
||
animationList.push_back("lord_abad.ani");
|
||
animationList.push_back("robot.ani");
|
||
animationList.push_back("matatunos.ani");
|
||
animationList.push_back("mummy.ani");
|
||
animationList.push_back("paco.ani");
|
||
animationList.push_back("elsa.ani");
|
||
animationList.push_back("qvoid.ani");
|
||
animationList.push_back("sam.ani");
|
||
animationList.push_back("sigmasua.ani");
|
||
animationList.push_back("spider.ani");
|
||
animationList.push_back("spark.ani");
|
||
animationList.push_back("tree_thing.ani");
|
||
animationList.push_back("tuno.ani");
|
||
animationList.push_back("tv_panel.ani");
|
||
animationList.push_back("tv.ani");
|
||
animationList.push_back("shock.ani");
|
||
animationList.push_back("upv_student.ani");
|
||
animationList.push_back("wave.ani");
|
||
animationList.push_back("z80.ani");
|
||
|
||
// Player
|
||
animationList.push_back("player.ani");
|
||
|
||
resource->loadAnimations(animationList);
|
||
|
||
// Offsets
|
||
std::vector<std::string> offsetsList;
|
||
offsetsList.push_back("smb2.txt");
|
||
|
||
resource->loadOffsets(offsetsList);
|
||
}
|
||
|
||
else if (section->name == SECTION_PROG_GAME_OVER)
|
||
{
|
||
// Texturas
|
||
std::vector<std::string> textureList;
|
||
textureList.push_back("smb2.png");
|
||
textureList.push_back("player_game_over.png");
|
||
textureList.push_back("tv.png");
|
||
|
||
resource->loadTextures(textureList);
|
||
|
||
// Animaciones
|
||
std::vector<std::string> animationList;
|
||
animationList.push_back("player_game_over.ani");
|
||
animationList.push_back("tv.ani");
|
||
|
||
resource->loadAnimations(animationList);
|
||
|
||
// Offsets
|
||
std::vector<std::string> offsetsList;
|
||
offsetsList.push_back("smb2.txt");
|
||
|
||
resource->loadOffsets(offsetsList);
|
||
}
|
||
|
||
else if (section->name == SECTION_PROG_GAME || section->name == SECTION_PROG_DEMO)
|
||
{
|
||
// Texturas
|
||
std::vector<std::string> textureList;
|
||
|
||
// Jugador
|
||
if (options->cheat.altSkin)
|
||
{
|
||
textureList.push_back("player2.png");
|
||
}
|
||
else
|
||
{
|
||
textureList.push_back("player.png");
|
||
}
|
||
|
||
// Tilesets
|
||
textureList.push_back("standard.png");
|
||
textureList.push_back("standard_zxarne.png");
|
||
|
||
// Enemigos
|
||
textureList.push_back("abad_bell.png");
|
||
textureList.push_back("abad.png");
|
||
textureList.push_back("aerojailer.png");
|
||
textureList.push_back("amstrad_cs.png");
|
||
textureList.push_back("flying_arounder.png");
|
||
textureList.push_back("stopped_arounder.png");
|
||
textureList.push_back("walking_arounder.png");
|
||
textureList.push_back("arounder.png");
|
||
textureList.push_back("arounders_door.png");
|
||
textureList.push_back("arounders_machine.png");
|
||
textureList.push_back("bat.png");
|
||
textureList.push_back("batman_bell.png");
|
||
textureList.push_back("batman_fire.png");
|
||
textureList.push_back("batman.png");
|
||
textureList.push_back("bell.png");
|
||
textureList.push_back("bin.png");
|
||
textureList.push_back("bird.png");
|
||
textureList.push_back("breakout.png");
|
||
textureList.push_back("bry.png");
|
||
textureList.push_back("chip.png");
|
||
textureList.push_back("code.png");
|
||
textureList.push_back("congo.png");
|
||
textureList.push_back("crosshair.png");
|
||
textureList.push_back("demon.png");
|
||
textureList.push_back("dimallas.png");
|
||
textureList.push_back("floppy.png");
|
||
textureList.push_back("dong.png");
|
||
textureList.push_back("guitar.png");
|
||
textureList.push_back("heavy.png");
|
||
textureList.push_back("jailer_#1.png");
|
||
textureList.push_back("jailer_#2.png");
|
||
textureList.push_back("jailer_#3.png");
|
||
textureList.push_back("jailbattle_alien.png");
|
||
textureList.push_back("jailbattle_human.png");
|
||
textureList.push_back("jeannine.png");
|
||
textureList.push_back("lamp.png");
|
||
textureList.push_back("lord_abad.png");
|
||
textureList.push_back("matatunos.png");
|
||
textureList.push_back("mummy.png");
|
||
textureList.push_back("paco.png");
|
||
textureList.push_back("pepe_rosita_job.png");
|
||
textureList.push_back("elsa.png");
|
||
textureList.push_back("qvoid.png");
|
||
textureList.push_back("robot.png");
|
||
textureList.push_back("sam.png");
|
||
textureList.push_back("shock.png");
|
||
textureList.push_back("shooting_star.png");
|
||
textureList.push_back("sigmasua.png");
|
||
textureList.push_back("spark.png");
|
||
textureList.push_back("spider.png");
|
||
textureList.push_back("tree_thing.png");
|
||
textureList.push_back("tuno.png");
|
||
textureList.push_back("tv_panel.png");
|
||
textureList.push_back("tv.png");
|
||
textureList.push_back("upv_student.png");
|
||
textureList.push_back("wave.png");
|
||
textureList.push_back("z80.png");
|
||
|
||
// Items
|
||
textureList.push_back("items.png");
|
||
|
||
// Texto
|
||
textureList.push_back("smb2.png");
|
||
textureList.push_back("debug.png");
|
||
|
||
resource->loadTextures(textureList);
|
||
|
||
// Animaciones
|
||
std::vector<std::string> animationList;
|
||
|
||
// Jugador
|
||
if (options->cheat.altSkin)
|
||
{
|
||
animationList.push_back("player2.ani");
|
||
}
|
||
else
|
||
{
|
||
animationList.push_back("player.ani");
|
||
}
|
||
|
||
// Enemigos
|
||
animationList.push_back("abad_bell.ani");
|
||
animationList.push_back("abad.ani");
|
||
animationList.push_back("aerojailer.ani");
|
||
animationList.push_back("amstrad_cs.ani");
|
||
animationList.push_back("flying_arounder.ani");
|
||
animationList.push_back("stopped_arounder.ani");
|
||
animationList.push_back("walking_arounder.ani");
|
||
animationList.push_back("arounder.ani");
|
||
animationList.push_back("arounders_door.ani");
|
||
animationList.push_back("arounders_machine.ani");
|
||
animationList.push_back("bat.ani");
|
||
animationList.push_back("batman_bell.ani");
|
||
animationList.push_back("batman_fire.ani");
|
||
animationList.push_back("batman.ani");
|
||
animationList.push_back("bell.ani");
|
||
animationList.push_back("bin.ani");
|
||
animationList.push_back("bird.ani");
|
||
animationList.push_back("breakout.ani");
|
||
animationList.push_back("bry.ani");
|
||
animationList.push_back("chip.ani");
|
||
animationList.push_back("code.ani");
|
||
animationList.push_back("congo.ani");
|
||
animationList.push_back("crosshair.ani");
|
||
animationList.push_back("demon.ani");
|
||
animationList.push_back("dimallas.ani");
|
||
animationList.push_back("floppy.ani");
|
||
animationList.push_back("dong.ani");
|
||
animationList.push_back("guitar.ani");
|
||
animationList.push_back("heavy.ani");
|
||
animationList.push_back("jailer_#1.ani");
|
||
animationList.push_back("jailer_#2.ani");
|
||
animationList.push_back("jailer_#3.ani");
|
||
animationList.push_back("jailbattle_alien.ani");
|
||
animationList.push_back("jailbattle_human.ani");
|
||
animationList.push_back("jeannine.ani");
|
||
animationList.push_back("lamp.ani");
|
||
animationList.push_back("lord_abad.ani");
|
||
animationList.push_back("matatunos.ani");
|
||
animationList.push_back("mummy.ani");
|
||
animationList.push_back("paco.ani");
|
||
animationList.push_back("pepe_rosita_job.ani");
|
||
animationList.push_back("elsa.ani");
|
||
animationList.push_back("qvoid.ani");
|
||
animationList.push_back("robot.ani");
|
||
animationList.push_back("sam.ani");
|
||
animationList.push_back("shock.ani");
|
||
animationList.push_back("shooting_star.ani");
|
||
animationList.push_back("sigmasua.ani");
|
||
animationList.push_back("spark.ani");
|
||
animationList.push_back("spider.ani");
|
||
animationList.push_back("tree_thing.ani");
|
||
animationList.push_back("tuno.ani");
|
||
animationList.push_back("tv_panel.ani");
|
||
animationList.push_back("tv.ani");
|
||
animationList.push_back("upv_student.ani");
|
||
animationList.push_back("wave.ani");
|
||
animationList.push_back("z80.ani");
|
||
|
||
resource->loadAnimations(animationList);
|
||
|
||
// Offsets
|
||
std::vector<std::string> offsetsList;
|
||
offsetsList.push_back("smb2.txt");
|
||
offsetsList.push_back("debug.txt");
|
||
|
||
resource->loadOffsets(offsetsList);
|
||
|
||
// TileMaps
|
||
std::vector<std::string> tileMapList;
|
||
tileMapList.push_back("01.tmx");
|
||
tileMapList.push_back("02.tmx");
|
||
tileMapList.push_back("03.tmx");
|
||
tileMapList.push_back("04.tmx");
|
||
tileMapList.push_back("05.tmx");
|
||
tileMapList.push_back("06.tmx");
|
||
tileMapList.push_back("07.tmx");
|
||
tileMapList.push_back("08.tmx");
|
||
tileMapList.push_back("09.tmx");
|
||
tileMapList.push_back("10.tmx");
|
||
tileMapList.push_back("11.tmx");
|
||
tileMapList.push_back("12.tmx");
|
||
tileMapList.push_back("13.tmx");
|
||
tileMapList.push_back("14.tmx");
|
||
tileMapList.push_back("15.tmx");
|
||
tileMapList.push_back("16.tmx");
|
||
tileMapList.push_back("17.tmx");
|
||
tileMapList.push_back("18.tmx");
|
||
tileMapList.push_back("19.tmx");
|
||
tileMapList.push_back("20.tmx");
|
||
tileMapList.push_back("21.tmx");
|
||
tileMapList.push_back("22.tmx");
|
||
tileMapList.push_back("23.tmx");
|
||
tileMapList.push_back("24.tmx");
|
||
tileMapList.push_back("25.tmx");
|
||
tileMapList.push_back("26.tmx");
|
||
tileMapList.push_back("27.tmx");
|
||
tileMapList.push_back("28.tmx");
|
||
tileMapList.push_back("29.tmx");
|
||
tileMapList.push_back("30.tmx");
|
||
tileMapList.push_back("31.tmx");
|
||
tileMapList.push_back("32.tmx");
|
||
tileMapList.push_back("33.tmx");
|
||
tileMapList.push_back("34.tmx");
|
||
tileMapList.push_back("35.tmx");
|
||
tileMapList.push_back("36.tmx");
|
||
tileMapList.push_back("37.tmx");
|
||
tileMapList.push_back("38.tmx");
|
||
tileMapList.push_back("39.tmx");
|
||
tileMapList.push_back("40.tmx");
|
||
tileMapList.push_back("41.tmx");
|
||
tileMapList.push_back("42.tmx");
|
||
tileMapList.push_back("43.tmx");
|
||
tileMapList.push_back("44.tmx");
|
||
tileMapList.push_back("45.tmx");
|
||
tileMapList.push_back("46.tmx");
|
||
tileMapList.push_back("47.tmx");
|
||
tileMapList.push_back("48.tmx");
|
||
tileMapList.push_back("49.tmx");
|
||
tileMapList.push_back("50.tmx");
|
||
tileMapList.push_back("51.tmx");
|
||
tileMapList.push_back("52.tmx");
|
||
tileMapList.push_back("53.tmx");
|
||
tileMapList.push_back("54.tmx");
|
||
tileMapList.push_back("55.tmx");
|
||
tileMapList.push_back("56.tmx");
|
||
tileMapList.push_back("57.tmx");
|
||
tileMapList.push_back("58.tmx");
|
||
tileMapList.push_back("59.tmx");
|
||
tileMapList.push_back("60.tmx");
|
||
|
||
resource->loadTileMaps(tileMapList);
|
||
|
||
// Habitaciones
|
||
std::vector<std::string> roomList;
|
||
roomList.push_back("01.room");
|
||
roomList.push_back("02.room");
|
||
roomList.push_back("03.room");
|
||
roomList.push_back("04.room");
|
||
roomList.push_back("05.room");
|
||
roomList.push_back("06.room");
|
||
roomList.push_back("07.room");
|
||
roomList.push_back("08.room");
|
||
roomList.push_back("09.room");
|
||
roomList.push_back("10.room");
|
||
roomList.push_back("11.room");
|
||
roomList.push_back("12.room");
|
||
roomList.push_back("13.room");
|
||
roomList.push_back("14.room");
|
||
roomList.push_back("15.room");
|
||
roomList.push_back("16.room");
|
||
roomList.push_back("17.room");
|
||
roomList.push_back("18.room");
|
||
roomList.push_back("19.room");
|
||
roomList.push_back("20.room");
|
||
roomList.push_back("21.room");
|
||
roomList.push_back("22.room");
|
||
roomList.push_back("23.room");
|
||
roomList.push_back("24.room");
|
||
roomList.push_back("25.room");
|
||
roomList.push_back("26.room");
|
||
roomList.push_back("27.room");
|
||
roomList.push_back("28.room");
|
||
roomList.push_back("29.room");
|
||
roomList.push_back("30.room");
|
||
roomList.push_back("31.room");
|
||
roomList.push_back("32.room");
|
||
roomList.push_back("33.room");
|
||
roomList.push_back("34.room");
|
||
roomList.push_back("35.room");
|
||
roomList.push_back("36.room");
|
||
roomList.push_back("37.room");
|
||
roomList.push_back("38.room");
|
||
roomList.push_back("39.room");
|
||
roomList.push_back("40.room");
|
||
roomList.push_back("41.room");
|
||
roomList.push_back("42.room");
|
||
roomList.push_back("43.room");
|
||
roomList.push_back("44.room");
|
||
roomList.push_back("45.room");
|
||
roomList.push_back("46.room");
|
||
roomList.push_back("47.room");
|
||
roomList.push_back("48.room");
|
||
roomList.push_back("49.room");
|
||
roomList.push_back("50.room");
|
||
roomList.push_back("51.room");
|
||
roomList.push_back("52.room");
|
||
roomList.push_back("53.room");
|
||
roomList.push_back("54.room");
|
||
roomList.push_back("55.room");
|
||
roomList.push_back("56.room");
|
||
roomList.push_back("57.room");
|
||
roomList.push_back("58.room");
|
||
roomList.push_back("59.room");
|
||
roomList.push_back("60.room");
|
||
|
||
resource->loadRooms(roomList);
|
||
}
|
||
|
||
if (options->console)
|
||
{
|
||
std::cout << "** RESOURCES LOADED" << std::endl;
|
||
}
|
||
}
|
||
|
||
// Asigna variables a partir de dos cadenas
|
||
bool Director::setOptions(options_t *options, std::string var, std::string value)
|
||
{
|
||
// Indicador de éxito en la asignación
|
||
bool success = true;
|
||
|
||
if (var == "configVersion")
|
||
{
|
||
options->configVersion = value;
|
||
}
|
||
|
||
else if (var == "keys")
|
||
{
|
||
if (value == "OPQA")
|
||
{
|
||
options->keys = ctrl_opqa;
|
||
}
|
||
else if (value == "WASD")
|
||
{
|
||
options->keys = ctrl_wasd;
|
||
}
|
||
else
|
||
{
|
||
options->keys = ctrl_cursor;
|
||
}
|
||
}
|
||
|
||
else if (var == "videoMode")
|
||
{
|
||
if (value == "SDL_WINDOW_FULLSCREEN_DESKTOP")
|
||
{
|
||
options->videoMode = SDL_WINDOW_FULLSCREEN_DESKTOP;
|
||
}
|
||
else if (value == "SDL_WINDOW_FULLSCREEN")
|
||
{
|
||
options->videoMode = SDL_WINDOW_FULLSCREEN;
|
||
}
|
||
else
|
||
{
|
||
options->videoMode = 0;
|
||
}
|
||
}
|
||
|
||
else if (var == "windowSize")
|
||
{
|
||
options->windowSize = std::stoi(value);
|
||
if ((options->windowSize < 1) || (options->windowSize > 4))
|
||
{
|
||
options->windowSize = 3;
|
||
}
|
||
}
|
||
|
||
else if (var == "filter")
|
||
{
|
||
if (value == "FILTER_LINEAL")
|
||
{
|
||
options->filter = FILTER_LINEAL;
|
||
}
|
||
else
|
||
{
|
||
options->filter = FILTER_NEAREST;
|
||
}
|
||
}
|
||
|
||
else if (var == "vSync")
|
||
{
|
||
options->vSync = stringToBool(value);
|
||
}
|
||
|
||
else if (var == "integerScale")
|
||
{
|
||
options->integerScale = stringToBool(value);
|
||
}
|
||
|
||
else if (var == "keepAspect")
|
||
{
|
||
options->keepAspect = stringToBool(value);
|
||
}
|
||
|
||
else if (var == "borderEnabled")
|
||
{
|
||
options->borderEnabled = stringToBool(value);
|
||
}
|
||
|
||
else if (var == "borderWidth")
|
||
{
|
||
options->borderWidth = std::stoi(value);
|
||
}
|
||
|
||
else if (var == "borderHeight")
|
||
{
|
||
options->borderHeight = std::stoi(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 == "enabled")
|
||
{
|
||
options->online.enabled = stringToBool(value);
|
||
}
|
||
|
||
else if (var == "server")
|
||
{
|
||
options->online.server = value;
|
||
}
|
||
|
||
else if (var == "port")
|
||
{
|
||
if (value == "")
|
||
{
|
||
value = "0";
|
||
}
|
||
options->online.port = std::stoi(value);
|
||
}
|
||
|
||
else if (var == "jailerID")
|
||
{
|
||
options->online.jailerID = value;
|
||
}
|
||
|
||
else if (var == "notifications.posH")
|
||
{
|
||
if (value == "pos_left")
|
||
{
|
||
options->notifications.posH = pos_left;
|
||
}
|
||
else if (value == "pos_middle")
|
||
{
|
||
options->notifications.posH = pos_middle;
|
||
}
|
||
else
|
||
{
|
||
options->notifications.posH = pos_right;
|
||
}
|
||
}
|
||
|
||
else if (var == "notifications.posV")
|
||
{
|
||
if (value == "pos_top")
|
||
{
|
||
options->notifications.posV = pos_top;
|
||
}
|
||
else
|
||
{
|
||
options->notifications.posV = pos_bottom;
|
||
}
|
||
}
|
||
|
||
else if (var == "notifications.sound")
|
||
{
|
||
options->notifications.sound = stringToBool(value);
|
||
}
|
||
|
||
else if (var == "" || var.substr(0, 1) == "#")
|
||
{
|
||
}
|
||
|
||
else
|
||
{
|
||
success = false;
|
||
}
|
||
|
||
return success;
|
||
}
|
||
|
||
// Inicia las variables necesarias para arrancar el programa
|
||
void Director::initInput()
|
||
{
|
||
// Establece si ha de mostrar mensajes
|
||
input->setVerbose(options->console);
|
||
|
||
// Busca si hay un mando conectado
|
||
input->discoverGameController();
|
||
|
||
// Teclado - Movimiento
|
||
if (options->keys == ctrl_cursor)
|
||
{
|
||
input->bindKey(input_jump, SDL_SCANCODE_UP);
|
||
input->bindKey(input_left, SDL_SCANCODE_LEFT);
|
||
input->bindKey(input_right, SDL_SCANCODE_RIGHT);
|
||
input->bindKey(input_up, SDL_SCANCODE_UP);
|
||
input->bindKey(input_down, SDL_SCANCODE_DOWN);
|
||
}
|
||
else if (options->keys == ctrl_opqa)
|
||
{
|
||
input->bindKey(input_jump, SDL_SCANCODE_Q);
|
||
input->bindKey(input_left, SDL_SCANCODE_O);
|
||
input->bindKey(input_right, SDL_SCANCODE_P);
|
||
input->bindKey(input_up, SDL_SCANCODE_Q);
|
||
input->bindKey(input_down, SDL_SCANCODE_A);
|
||
}
|
||
else if (options->keys == ctrl_wasd)
|
||
{
|
||
input->bindKey(input_jump, SDL_SCANCODE_W);
|
||
input->bindKey(input_left, SDL_SCANCODE_A);
|
||
input->bindKey(input_right, SDL_SCANCODE_D);
|
||
input->bindKey(input_up, SDL_SCANCODE_W);
|
||
input->bindKey(input_down, SDL_SCANCODE_S);
|
||
}
|
||
|
||
// Teclado - Otros
|
||
input->bindKey(input_accept, SDL_SCANCODE_RETURN);
|
||
input->bindKey(input_cancel, SDL_SCANCODE_ESCAPE);
|
||
input->bindKey(input_pause, SDL_SCANCODE_H);
|
||
input->bindKey(input_exit, SDL_SCANCODE_ESCAPE);
|
||
input->bindKey(input_window_dec_size, SDL_SCANCODE_F1);
|
||
input->bindKey(input_window_inc_size, SDL_SCANCODE_F2);
|
||
input->bindKey(input_window_fullscreen, SDL_SCANCODE_F3);
|
||
input->bindKey(input_swap_palette, SDL_SCANCODE_F5);
|
||
input->bindKey(input_switch_music, SDL_SCANCODE_M);
|
||
input->bindKey(input_toggle_border, SDL_SCANCODE_B);
|
||
|
||
// Mando - Movimiento
|
||
input->bindGameControllerButton(input_jump, SDL_CONTROLLER_BUTTON_B);
|
||
input->bindGameControllerButton(input_left, SDL_CONTROLLER_BUTTON_DPAD_LEFT);
|
||
input->bindGameControllerButton(input_right, SDL_CONTROLLER_BUTTON_DPAD_RIGHT);
|
||
|
||
// Mando - Otros
|
||
input->bindGameControllerButton(input_accept, SDL_CONTROLLER_BUTTON_B);
|
||
input->bindGameControllerButton(input_cancel, SDL_CONTROLLER_BUTTON_A);
|
||
#ifdef GAME_CONSOLE
|
||
input->bindGameControllerButton(input_pause, SDL_CONTROLLER_BUTTON_BACK);
|
||
input->bindGameControllerButton(input_exit, SDL_CONTROLLER_BUTTON_START);
|
||
#else
|
||
input->bindGameControllerButton(input_pause, SDL_CONTROLLER_BUTTON_START);
|
||
input->bindGameControllerButton(input_exit, SDL_CONTROLLER_BUTTON_BACK);
|
||
#endif
|
||
input->bindGameControllerButton(input_swap_palette, SDL_CONTROLLER_BUTTON_LEFTSHOULDER);
|
||
input->bindGameControllerButton(input_switch_music, SDL_CONTROLLER_BUTTON_RIGHTSHOULDER);
|
||
input->bindGameControllerButton(input_toggle_border, SDL_CONTROLLER_BUTTON_X);
|
||
}
|
||
|
||
// Inicializa JailAudio
|
||
void Director::initJailAudio()
|
||
{
|
||
JA_Init(48000, AUDIO_S16, 2);
|
||
}
|
||
|
||
// Arranca SDL y crea la ventana
|
||
bool Director::initSDL()
|
||
{
|
||
// Indicador de éxito
|
||
bool success = true;
|
||
|
||
// Inicializa SDL
|
||
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_GAMECONTROLLER | SDL_INIT_AUDIO) < 0)
|
||
{
|
||
if (options->console)
|
||
{
|
||
std::cout << "SDL could not initialize!\nSDL Error: " << SDL_GetError() << std::endl;
|
||
}
|
||
success = false;
|
||
}
|
||
else
|
||
{
|
||
// Inicia el generador de numeros aleatorios
|
||
std::srand(static_cast<unsigned int>(SDL_GetTicks()));
|
||
|
||
// Establece el filtro de la textura a nearest
|
||
if (!SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, std::to_string(options->filter).c_str()))
|
||
{
|
||
if (options->console)
|
||
{
|
||
std::cout << "Warning: Nearest texture filtering not enabled!\n";
|
||
}
|
||
}
|
||
|
||
// Crea la ventana
|
||
int incW = 0;
|
||
int incH = 0;
|
||
if (options->borderEnabled)
|
||
{
|
||
incW = options->borderWidth * 2;
|
||
incH = options->borderHeight * 2;
|
||
}
|
||
|
||
window = SDL_CreateWindow(WINDOW_CAPTION, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, (options->gameWidth + incW) * options->windowSize, (options->gameHeight + incH) * options->windowSize, SDL_WINDOW_SHOWN | SDL_WINDOW_ALLOW_HIGHDPI);
|
||
if (window == nullptr)
|
||
{
|
||
if (options->console)
|
||
{
|
||
std::cout << "Window could not be created!\nSDL Error: " << SDL_GetError() << std::endl;
|
||
}
|
||
success = false;
|
||
}
|
||
else
|
||
{
|
||
// Crea un renderizador para la ventana. El vsync se activa en funcion de las opciones
|
||
//Uint32 flags = SDL_RENDERER_SOFTWARE;
|
||
//Uint32 flags = SDL_RENDERER_ACCELERATED;
|
||
Uint32 flags = 0;
|
||
if (options->vSync)
|
||
{
|
||
flags = flags | SDL_RENDERER_PRESENTVSYNC;
|
||
}
|
||
renderer = SDL_CreateRenderer(window, -1, flags);
|
||
|
||
if (renderer == nullptr)
|
||
{
|
||
if (options->console)
|
||
{
|
||
std::cout << "Renderer could not be created!\nSDL Error: " << SDL_GetError() << std::endl;
|
||
}
|
||
success = false;
|
||
}
|
||
else
|
||
{
|
||
// Inicializa el color de renderizado
|
||
SDL_SetRenderDrawColor(renderer, 0x00, 0x00, 0x00, 0xFF);
|
||
|
||
// Establece el tamaño del buffer de renderizado
|
||
SDL_RenderSetLogicalSize(renderer, options->gameWidth, options->gameHeight);
|
||
|
||
// Establece el modo de mezcla
|
||
SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_BLEND);
|
||
}
|
||
}
|
||
}
|
||
|
||
if (options->console)
|
||
{
|
||
std::cout << std::endl;
|
||
}
|
||
return success;
|
||
}
|
||
|
||
// Crea el indice de ficheros
|
||
bool Director::setFileList()
|
||
{
|
||
#ifdef MACOS_BUNDLE
|
||
const std::string prefix = "/../Resources";
|
||
#else
|
||
const std::string prefix = "";
|
||
#endif
|
||
|
||
// Texto
|
||
asset->add(prefix + "/data/font/smb2.png", t_font);
|
||
asset->add(prefix + "/data/font/smb2.txt", t_font);
|
||
asset->add(prefix + "/data/font/debug.png", t_font);
|
||
asset->add(prefix + "/data/font/debug.txt", t_font);
|
||
asset->add(prefix + "/data/font/gauntlet.png", t_font);
|
||
asset->add(prefix + "/data/font/gauntlet.txt", t_font);
|
||
asset->add(prefix + "/data/font/subatomic.png", t_font);
|
||
asset->add(prefix + "/data/font/subatomic.txt", t_font);
|
||
|
||
// Datos
|
||
asset->add(prefix + "/data/input/gamecontrollerdb.txt", t_data);
|
||
|
||
// Ficheros de sistema
|
||
asset->add(systemFolder + "/config.txt", t_data, false, true);
|
||
asset->add(systemFolder + "/stats_buffer.csv", t_data, false, true);
|
||
asset->add(systemFolder + "/stats.csv", t_data, false, true);
|
||
asset->add(systemFolder + "/cheevos.bin", t_data, false, true);
|
||
|
||
// Notificaciones
|
||
asset->add(prefix + "/data/notifications/notify.png", t_bitmap);
|
||
|
||
// Habitaciones
|
||
asset->add(prefix + "/data/room/01.room", t_room);
|
||
asset->add(prefix + "/data/room/02.room", t_room);
|
||
asset->add(prefix + "/data/room/03.room", t_room);
|
||
asset->add(prefix + "/data/room/04.room", t_room);
|
||
asset->add(prefix + "/data/room/05.room", t_room);
|
||
asset->add(prefix + "/data/room/06.room", t_room);
|
||
asset->add(prefix + "/data/room/07.room", t_room);
|
||
asset->add(prefix + "/data/room/08.room", t_room);
|
||
asset->add(prefix + "/data/room/09.room", t_room);
|
||
asset->add(prefix + "/data/room/10.room", t_room);
|
||
asset->add(prefix + "/data/room/11.room", t_room);
|
||
asset->add(prefix + "/data/room/12.room", t_room);
|
||
asset->add(prefix + "/data/room/13.room", t_room);
|
||
asset->add(prefix + "/data/room/14.room", t_room);
|
||
asset->add(prefix + "/data/room/15.room", t_room);
|
||
asset->add(prefix + "/data/room/16.room", t_room);
|
||
asset->add(prefix + "/data/room/17.room", t_room);
|
||
asset->add(prefix + "/data/room/18.room", t_room);
|
||
asset->add(prefix + "/data/room/19.room", t_room);
|
||
asset->add(prefix + "/data/room/20.room", t_room);
|
||
asset->add(prefix + "/data/room/21.room", t_room);
|
||
asset->add(prefix + "/data/room/22.room", t_room);
|
||
asset->add(prefix + "/data/room/23.room", t_room);
|
||
asset->add(prefix + "/data/room/24.room", t_room);
|
||
asset->add(prefix + "/data/room/25.room", t_room);
|
||
asset->add(prefix + "/data/room/26.room", t_room);
|
||
asset->add(prefix + "/data/room/27.room", t_room);
|
||
asset->add(prefix + "/data/room/28.room", t_room);
|
||
asset->add(prefix + "/data/room/29.room", t_room);
|
||
asset->add(prefix + "/data/room/30.room", t_room);
|
||
asset->add(prefix + "/data/room/31.room", t_room);
|
||
asset->add(prefix + "/data/room/32.room", t_room);
|
||
asset->add(prefix + "/data/room/33.room", t_room);
|
||
asset->add(prefix + "/data/room/34.room", t_room);
|
||
asset->add(prefix + "/data/room/35.room", t_room);
|
||
asset->add(prefix + "/data/room/36.room", t_room);
|
||
asset->add(prefix + "/data/room/37.room", t_room);
|
||
asset->add(prefix + "/data/room/38.room", t_room);
|
||
asset->add(prefix + "/data/room/39.room", t_room);
|
||
asset->add(prefix + "/data/room/40.room", t_room);
|
||
asset->add(prefix + "/data/room/41.room", t_room);
|
||
asset->add(prefix + "/data/room/42.room", t_room);
|
||
asset->add(prefix + "/data/room/43.room", t_room);
|
||
asset->add(prefix + "/data/room/44.room", t_room);
|
||
asset->add(prefix + "/data/room/45.room", t_room);
|
||
asset->add(prefix + "/data/room/46.room", t_room);
|
||
asset->add(prefix + "/data/room/47.room", t_room);
|
||
asset->add(prefix + "/data/room/48.room", t_room);
|
||
asset->add(prefix + "/data/room/49.room", t_room);
|
||
asset->add(prefix + "/data/room/50.room", t_room);
|
||
asset->add(prefix + "/data/room/51.room", t_room);
|
||
asset->add(prefix + "/data/room/52.room", t_room);
|
||
asset->add(prefix + "/data/room/53.room", t_room);
|
||
asset->add(prefix + "/data/room/54.room", t_room);
|
||
asset->add(prefix + "/data/room/55.room", t_room);
|
||
asset->add(prefix + "/data/room/56.room", t_room);
|
||
asset->add(prefix + "/data/room/57.room", t_room);
|
||
asset->add(prefix + "/data/room/58.room", t_room);
|
||
asset->add(prefix + "/data/room/59.room", t_room);
|
||
asset->add(prefix + "/data/room/60.room", t_room);
|
||
|
||
// Tilemaps
|
||
asset->add(prefix + "/data/room/01.tmx", t_room);
|
||
asset->add(prefix + "/data/room/02.tmx", t_room);
|
||
asset->add(prefix + "/data/room/03.tmx", t_room);
|
||
asset->add(prefix + "/data/room/04.tmx", t_room);
|
||
asset->add(prefix + "/data/room/05.tmx", t_room);
|
||
asset->add(prefix + "/data/room/06.tmx", t_room);
|
||
asset->add(prefix + "/data/room/07.tmx", t_room);
|
||
asset->add(prefix + "/data/room/08.tmx", t_room);
|
||
asset->add(prefix + "/data/room/09.tmx", t_room);
|
||
asset->add(prefix + "/data/room/10.tmx", t_room);
|
||
asset->add(prefix + "/data/room/11.tmx", t_room);
|
||
asset->add(prefix + "/data/room/12.tmx", t_room);
|
||
asset->add(prefix + "/data/room/13.tmx", t_room);
|
||
asset->add(prefix + "/data/room/14.tmx", t_room);
|
||
asset->add(prefix + "/data/room/15.tmx", t_room);
|
||
asset->add(prefix + "/data/room/16.tmx", t_room);
|
||
asset->add(prefix + "/data/room/17.tmx", t_room);
|
||
asset->add(prefix + "/data/room/18.tmx", t_room);
|
||
asset->add(prefix + "/data/room/19.tmx", t_room);
|
||
asset->add(prefix + "/data/room/20.tmx", t_room);
|
||
asset->add(prefix + "/data/room/21.tmx", t_room);
|
||
asset->add(prefix + "/data/room/22.tmx", t_room);
|
||
asset->add(prefix + "/data/room/23.tmx", t_room);
|
||
asset->add(prefix + "/data/room/24.tmx", t_room);
|
||
asset->add(prefix + "/data/room/25.tmx", t_room);
|
||
asset->add(prefix + "/data/room/26.tmx", t_room);
|
||
asset->add(prefix + "/data/room/27.tmx", t_room);
|
||
asset->add(prefix + "/data/room/28.tmx", t_room);
|
||
asset->add(prefix + "/data/room/29.tmx", t_room);
|
||
asset->add(prefix + "/data/room/30.tmx", t_room);
|
||
asset->add(prefix + "/data/room/31.tmx", t_room);
|
||
asset->add(prefix + "/data/room/32.tmx", t_room);
|
||
asset->add(prefix + "/data/room/33.tmx", t_room);
|
||
asset->add(prefix + "/data/room/34.tmx", t_room);
|
||
asset->add(prefix + "/data/room/35.tmx", t_room);
|
||
asset->add(prefix + "/data/room/36.tmx", t_room);
|
||
asset->add(prefix + "/data/room/37.tmx", t_room);
|
||
asset->add(prefix + "/data/room/38.tmx", t_room);
|
||
asset->add(prefix + "/data/room/39.tmx", t_room);
|
||
asset->add(prefix + "/data/room/40.tmx", t_room);
|
||
asset->add(prefix + "/data/room/41.tmx", t_room);
|
||
asset->add(prefix + "/data/room/42.tmx", t_room);
|
||
asset->add(prefix + "/data/room/43.tmx", t_room);
|
||
asset->add(prefix + "/data/room/44.tmx", t_room);
|
||
asset->add(prefix + "/data/room/45.tmx", t_room);
|
||
asset->add(prefix + "/data/room/46.tmx", t_room);
|
||
asset->add(prefix + "/data/room/47.tmx", t_room);
|
||
asset->add(prefix + "/data/room/48.tmx", t_room);
|
||
asset->add(prefix + "/data/room/49.tmx", t_room);
|
||
asset->add(prefix + "/data/room/50.tmx", t_room);
|
||
asset->add(prefix + "/data/room/51.tmx", t_room);
|
||
asset->add(prefix + "/data/room/52.tmx", t_room);
|
||
asset->add(prefix + "/data/room/53.tmx", t_room);
|
||
asset->add(prefix + "/data/room/54.tmx", t_room);
|
||
asset->add(prefix + "/data/room/55.tmx", t_room);
|
||
asset->add(prefix + "/data/room/56.tmx", t_room);
|
||
asset->add(prefix + "/data/room/57.tmx", t_room);
|
||
asset->add(prefix + "/data/room/58.tmx", t_room);
|
||
asset->add(prefix + "/data/room/59.tmx", t_room);
|
||
asset->add(prefix + "/data/room/60.tmx", t_room);
|
||
|
||
// Tilesets
|
||
asset->add(prefix + "/data/tilesets/standard.png", t_bitmap);
|
||
asset->add(prefix + "/data/tilesets/standard_zxarne.png", t_bitmap);
|
||
|
||
// Enemigos
|
||
asset->add(prefix + "/data/enemies/abad_bell.ani", t_data);
|
||
asset->add(prefix + "/data/enemies/abad_bell.png", t_bitmap);
|
||
asset->add(prefix + "/data/enemies/abad.ani", t_data);
|
||
asset->add(prefix + "/data/enemies/abad.png", t_bitmap);
|
||
asset->add(prefix + "/data/enemies/amstrad_cs.ani", t_data);
|
||
asset->add(prefix + "/data/enemies/amstrad_cs.png", t_bitmap);
|
||
asset->add(prefix + "/data/enemies/flying_arounder.ani", t_data);
|
||
asset->add(prefix + "/data/enemies/flying_arounder.png", t_bitmap);
|
||
asset->add(prefix + "/data/enemies/stopped_arounder.ani", t_data);
|
||
asset->add(prefix + "/data/enemies/stopped_arounder.png", t_bitmap);
|
||
asset->add(prefix + "/data/enemies/walking_arounder.ani", t_data);
|
||
asset->add(prefix + "/data/enemies/walking_arounder.png", t_bitmap);
|
||
asset->add(prefix + "/data/enemies/arounders_door.ani", t_data);
|
||
asset->add(prefix + "/data/enemies/arounders_door.png", t_bitmap);
|
||
asset->add(prefix + "/data/enemies/arounders_machine.ani", t_data);
|
||
asset->add(prefix + "/data/enemies/arounders_machine.png", t_bitmap);
|
||
asset->add(prefix + "/data/enemies/bat.ani", t_data);
|
||
asset->add(prefix + "/data/enemies/bat.png", t_bitmap);
|
||
asset->add(prefix + "/data/enemies/batman_bell.ani", t_data);
|
||
asset->add(prefix + "/data/enemies/batman_bell.png", t_bitmap);
|
||
asset->add(prefix + "/data/enemies/batman_fire.ani", t_data);
|
||
asset->add(prefix + "/data/enemies/batman_fire.png", t_bitmap);
|
||
asset->add(prefix + "/data/enemies/batman.ani", t_data);
|
||
asset->add(prefix + "/data/enemies/batman.png", t_bitmap);
|
||
asset->add(prefix + "/data/enemies/bell.ani", t_data);
|
||
asset->add(prefix + "/data/enemies/bell.png", t_bitmap);
|
||
asset->add(prefix + "/data/enemies/bin.ani", t_data);
|
||
asset->add(prefix + "/data/enemies/bin.png", t_bitmap);
|
||
asset->add(prefix + "/data/enemies/bird.ani", t_data);
|
||
asset->add(prefix + "/data/enemies/bird.png", t_bitmap);
|
||
asset->add(prefix + "/data/enemies/breakout.ani", t_data);
|
||
asset->add(prefix + "/data/enemies/breakout.png", t_bitmap);
|
||
asset->add(prefix + "/data/enemies/bry.ani", t_data);
|
||
asset->add(prefix + "/data/enemies/bry.png", t_bitmap);
|
||
asset->add(prefix + "/data/enemies/chip.ani", t_data);
|
||
asset->add(prefix + "/data/enemies/chip.png", t_bitmap);
|
||
asset->add(prefix + "/data/enemies/code.ani", t_data);
|
||
asset->add(prefix + "/data/enemies/code.png", t_bitmap);
|
||
asset->add(prefix + "/data/enemies/congo.ani", t_data);
|
||
asset->add(prefix + "/data/enemies/congo.png", t_bitmap);
|
||
asset->add(prefix + "/data/enemies/crosshair.ani", t_data);
|
||
asset->add(prefix + "/data/enemies/crosshair.png", t_bitmap);
|
||
asset->add(prefix + "/data/enemies/demon.ani", t_data);
|
||
asset->add(prefix + "/data/enemies/demon.png", t_bitmap);
|
||
asset->add(prefix + "/data/enemies/dimallas.ani", t_data);
|
||
asset->add(prefix + "/data/enemies/dimallas.png", t_bitmap);
|
||
asset->add(prefix + "/data/enemies/floppy.ani", t_data);
|
||
asset->add(prefix + "/data/enemies/floppy.png", t_bitmap);
|
||
asset->add(prefix + "/data/enemies/dong.ani", t_data);
|
||
asset->add(prefix + "/data/enemies/dong.png", t_bitmap);
|
||
asset->add(prefix + "/data/enemies/guitar.ani", t_data);
|
||
asset->add(prefix + "/data/enemies/guitar.png", t_bitmap);
|
||
asset->add(prefix + "/data/enemies/heavy.ani", t_data);
|
||
asset->add(prefix + "/data/enemies/heavy.png", t_bitmap);
|
||
asset->add(prefix + "/data/enemies/jailer_#1.ani", t_data);
|
||
asset->add(prefix + "/data/enemies/jailer_#1.png", t_bitmap);
|
||
asset->add(prefix + "/data/enemies/jailer_#2.ani", t_data);
|
||
asset->add(prefix + "/data/enemies/jailer_#2.png", t_bitmap);
|
||
asset->add(prefix + "/data/enemies/jailer_#3.ani", t_data);
|
||
asset->add(prefix + "/data/enemies/jailer_#3.png", t_bitmap);
|
||
asset->add(prefix + "/data/enemies/jailbattle_alien.ani", t_data);
|
||
asset->add(prefix + "/data/enemies/jailbattle_alien.png", t_bitmap);
|
||
asset->add(prefix + "/data/enemies/jailbattle_human.ani", t_data);
|
||
asset->add(prefix + "/data/enemies/jailbattle_human.png", t_bitmap);
|
||
asset->add(prefix + "/data/enemies/jeannine.ani", t_data);
|
||
asset->add(prefix + "/data/enemies/jeannine.png", t_bitmap);
|
||
asset->add(prefix + "/data/enemies/lamp.ani", t_data);
|
||
asset->add(prefix + "/data/enemies/lamp.png", t_bitmap);
|
||
asset->add(prefix + "/data/enemies/lord_abad.ani", t_data);
|
||
asset->add(prefix + "/data/enemies/lord_abad.png", t_bitmap);
|
||
asset->add(prefix + "/data/enemies/matatunos.ani", t_data);
|
||
asset->add(prefix + "/data/enemies/matatunos.png", t_bitmap);
|
||
asset->add(prefix + "/data/enemies/mummy.ani", t_data);
|
||
asset->add(prefix + "/data/enemies/mummy.png", t_bitmap);
|
||
asset->add(prefix + "/data/enemies/paco.ani", t_data);
|
||
asset->add(prefix + "/data/enemies/paco.png", t_bitmap);
|
||
asset->add(prefix + "/data/enemies/elsa.ani", t_data);
|
||
asset->add(prefix + "/data/enemies/elsa.png", t_bitmap);
|
||
asset->add(prefix + "/data/enemies/qvoid.ani", t_data);
|
||
asset->add(prefix + "/data/enemies/qvoid.png", t_bitmap);
|
||
asset->add(prefix + "/data/enemies/robot.ani", t_data);
|
||
asset->add(prefix + "/data/enemies/robot.png", t_bitmap);
|
||
asset->add(prefix + "/data/enemies/sam.ani", t_data);
|
||
asset->add(prefix + "/data/enemies/sam.png", t_bitmap);
|
||
asset->add(prefix + "/data/enemies/shock.ani", t_data);
|
||
asset->add(prefix + "/data/enemies/shock.png", t_bitmap);
|
||
asset->add(prefix + "/data/enemies/sigmasua.ani", t_data);
|
||
asset->add(prefix + "/data/enemies/sigmasua.png", t_bitmap);
|
||
asset->add(prefix + "/data/enemies/spark.ani", t_data);
|
||
asset->add(prefix + "/data/enemies/spark.png", t_bitmap);
|
||
asset->add(prefix + "/data/enemies/special/aerojailer.ani", t_data);
|
||
asset->add(prefix + "/data/enemies/special/aerojailer.png", t_bitmap);
|
||
asset->add(prefix + "/data/enemies/special/arounder.ani", t_data);
|
||
asset->add(prefix + "/data/enemies/special/arounder.png", t_bitmap);
|
||
asset->add(prefix + "/data/enemies/special/pepe_rosita_job.ani", t_data);
|
||
asset->add(prefix + "/data/enemies/special/pepe_rosita_job.png", t_bitmap);
|
||
asset->add(prefix + "/data/enemies/special/shooting_star.ani", t_data);
|
||
asset->add(prefix + "/data/enemies/special/shooting_star.png", t_bitmap);
|
||
asset->add(prefix + "/data/enemies/spider.ani", t_data);
|
||
asset->add(prefix + "/data/enemies/spider.png", t_bitmap);
|
||
asset->add(prefix + "/data/enemies/tree_thing.ani", t_data);
|
||
asset->add(prefix + "/data/enemies/tree_thing.png", t_bitmap);
|
||
asset->add(prefix + "/data/enemies/tuno.ani", t_data);
|
||
asset->add(prefix + "/data/enemies/tuno.png", t_bitmap);
|
||
asset->add(prefix + "/data/enemies/tv_panel.ani", t_data);
|
||
asset->add(prefix + "/data/enemies/tv_panel.png", t_bitmap);
|
||
asset->add(prefix + "/data/enemies/tv.ani", t_data);
|
||
asset->add(prefix + "/data/enemies/tv.png", t_bitmap);
|
||
asset->add(prefix + "/data/enemies/upv_student.ani", t_data);
|
||
asset->add(prefix + "/data/enemies/upv_student.png", t_bitmap);
|
||
asset->add(prefix + "/data/enemies/wave.ani", t_data);
|
||
asset->add(prefix + "/data/enemies/wave.png", t_bitmap);
|
||
asset->add(prefix + "/data/enemies/z80.ani", t_data);
|
||
asset->add(prefix + "/data/enemies/z80.png", t_bitmap);
|
||
|
||
// Jugador
|
||
asset->add(prefix + "/data/player/player.png", t_bitmap);
|
||
asset->add(prefix + "/data/player/player.ani", t_data);
|
||
asset->add(prefix + "/data/player/player2.png", t_bitmap);
|
||
asset->add(prefix + "/data/player/player2.ani", t_data);
|
||
asset->add(prefix + "/data/player/player_game_over.png", t_bitmap);
|
||
asset->add(prefix + "/data/player/player_game_over.ani", t_data);
|
||
|
||
// Items
|
||
asset->add(prefix + "/data/items/items.png", t_bitmap);
|
||
|
||
// Musicas
|
||
asset->add(prefix + "/data/music/title.ogg", t_music);
|
||
asset->add(prefix + "/data/music/game.ogg", t_music);
|
||
asset->add(prefix + "/data/music/loading_sound1.ogg", t_music);
|
||
asset->add(prefix + "/data/music/loading_sound2.ogg", t_music);
|
||
asset->add(prefix + "/data/music/loading_sound3.ogg", t_music);
|
||
asset->add(prefix + "/data/music/ending1.ogg", t_music);
|
||
asset->add(prefix + "/data/music/ending2.ogg", t_music);
|
||
asset->add(prefix + "/data/music/game_over.ogg", t_music);
|
||
|
||
// Efectos de sonido
|
||
asset->add(prefix + "/data/sound/item.wav", t_sound);
|
||
asset->add(prefix + "/data/sound/death.wav", t_sound);
|
||
asset->add(prefix + "/data/sound/jump1.wav", t_sound);
|
||
asset->add(prefix + "/data/sound/jump2.wav", t_sound);
|
||
asset->add(prefix + "/data/sound/jump3.wav", t_sound);
|
||
asset->add(prefix + "/data/sound/jump4.wav", t_sound);
|
||
asset->add(prefix + "/data/sound/jump5.wav", t_sound);
|
||
asset->add(prefix + "/data/sound/jump6.wav", t_sound);
|
||
asset->add(prefix + "/data/sound/jump7.wav", t_sound);
|
||
asset->add(prefix + "/data/sound/jump8.wav", t_sound);
|
||
asset->add(prefix + "/data/sound/jump9.wav", t_sound);
|
||
asset->add(prefix + "/data/sound/jump10.wav", t_sound);
|
||
asset->add(prefix + "/data/sound/jump11.wav", t_sound);
|
||
asset->add(prefix + "/data/sound/jump12.wav", t_sound);
|
||
asset->add(prefix + "/data/sound/jump13.wav", t_sound);
|
||
asset->add(prefix + "/data/sound/jump14.wav", t_sound);
|
||
asset->add(prefix + "/data/sound/jump15.wav", t_sound);
|
||
asset->add(prefix + "/data/sound/jump16.wav", t_sound);
|
||
asset->add(prefix + "/data/sound/jump17.wav", t_sound);
|
||
asset->add(prefix + "/data/sound/jump18.wav", t_sound);
|
||
asset->add(prefix + "/data/sound/jump19.wav", t_sound);
|
||
asset->add(prefix + "/data/sound/jump20.wav", t_sound);
|
||
asset->add(prefix + "/data/sound/jump21.wav", t_sound);
|
||
asset->add(prefix + "/data/sound/jump22.wav", t_sound);
|
||
asset->add(prefix + "/data/sound/jump23.wav", t_sound);
|
||
asset->add(prefix + "/data/sound/jump24.wav", t_sound);
|
||
asset->add(prefix + "/data/sound/notify.wav", t_sound);
|
||
|
||
// Logo
|
||
asset->add(prefix + "/data/logo/jailgames.png", t_bitmap);
|
||
asset->add(prefix + "/data/logo/since_1998.png", t_bitmap);
|
||
|
||
// Intro
|
||
asset->add(prefix + "/data/title/loading_screen_bn.png", t_bitmap);
|
||
asset->add(prefix + "/data/title/loading_screen_color.png", t_bitmap);
|
||
asset->add(prefix + "/data/title/loading_screen_bn_zxarne.png", t_bitmap);
|
||
asset->add(prefix + "/data/title/loading_screen_color_zxarne.png", t_bitmap);
|
||
|
||
// Ending
|
||
asset->add(prefix + "/data/ending/ending1.png", t_bitmap);
|
||
asset->add(prefix + "/data/ending/ending1_zxarne.png", t_bitmap);
|
||
asset->add(prefix + "/data/ending/ending2.png", t_bitmap);
|
||
asset->add(prefix + "/data/ending/ending2_zxarne.png", t_bitmap);
|
||
asset->add(prefix + "/data/ending/ending3.png", t_bitmap);
|
||
asset->add(prefix + "/data/ending/ending3_zxarne.png", t_bitmap);
|
||
asset->add(prefix + "/data/ending/ending4.png", t_bitmap);
|
||
asset->add(prefix + "/data/ending/ending4_zxarne.png", t_bitmap);
|
||
asset->add(prefix + "/data/ending/ending5.png", t_bitmap);
|
||
asset->add(prefix + "/data/ending/ending5_zxarne.png", t_bitmap);
|
||
|
||
// Credits
|
||
asset->add(prefix + "/data/credits/shine.png", t_bitmap);
|
||
asset->add(prefix + "/data/credits/shine.ani", t_bitmap);
|
||
|
||
return asset->check();
|
||
}
|
||
|
||
// Ejecuta la seccion de juego con el logo
|
||
void Director::runLogo()
|
||
{
|
||
if (options->console)
|
||
{
|
||
std::cout << "\n* SECTION: LOGO" << std::endl;
|
||
}
|
||
loadResources(section);
|
||
logo = new Logo(renderer, screen, resource, asset, input, options, section);
|
||
logo->run();
|
||
delete logo;
|
||
resource->free();
|
||
}
|
||
|
||
// Ejecuta la seccion de juego de la introducción
|
||
void Director::runIntro()
|
||
{
|
||
if (options->console)
|
||
{
|
||
std::cout << "\n* SECTION: INTRO" << std::endl;
|
||
}
|
||
loadResources(section);
|
||
intro = new Intro(renderer, screen, resource, asset, input, options, section);
|
||
intro->run();
|
||
delete intro;
|
||
resource->free();
|
||
}
|
||
|
||
// Ejecuta la seccion de juego con el titulo y los menus
|
||
void Director::runTitle()
|
||
{
|
||
if (options->console)
|
||
{
|
||
std::cout << "\n* SECTION: TITLE" << std::endl;
|
||
}
|
||
if ((JA_GetMusicState() == JA_MUSIC_INVALID) || (JA_GetMusicState() == JA_MUSIC_STOPPED))
|
||
{
|
||
JA_PlayMusic(music);
|
||
}
|
||
loadResources(section);
|
||
title = new Title(renderer, screen, resource, asset, input, online, options, section);
|
||
title->run();
|
||
delete title;
|
||
resource->free();
|
||
}
|
||
|
||
// Ejecuta la seccion de los creditos del juego
|
||
void Director::runCredits()
|
||
{
|
||
if (options->console)
|
||
{
|
||
std::cout << "\n* SECTION: CREDITS" << std::endl;
|
||
}
|
||
loadResources(section);
|
||
credits = new Credits(renderer, screen, resource, asset, input, options, section);
|
||
credits->run();
|
||
delete credits;
|
||
resource->free();
|
||
}
|
||
|
||
// Ejecuta la seccion de la demo, donde se ven pantallas del juego
|
||
void Director::runDemo()
|
||
{
|
||
if (options->console)
|
||
{
|
||
std::cout << "\n* SECTION: DEMO" << std::endl;
|
||
}
|
||
loadResources(section);
|
||
demo = new Demo(renderer, screen, resource, asset, input, options, section, debug);
|
||
demo->run();
|
||
delete demo;
|
||
resource->free();
|
||
}
|
||
|
||
// Ejecuta la seccion del final del juego
|
||
void Director::runEnding()
|
||
{
|
||
if (options->console)
|
||
{
|
||
std::cout << "\n* SECTION: ENDING" << std::endl;
|
||
}
|
||
loadResources(section);
|
||
ending = new Ending(renderer, screen, resource, asset, input, options, section);
|
||
ending->run();
|
||
delete ending;
|
||
resource->free();
|
||
}
|
||
|
||
// Ejecuta la seccion del final del juego
|
||
void Director::runEnding2()
|
||
{
|
||
if (options->console)
|
||
{
|
||
std::cout << "\n* SECTION: ENDING2" << std::endl;
|
||
}
|
||
loadResources(section);
|
||
ending2 = new Ending2(renderer, screen, resource, asset, input, options, section);
|
||
ending2->run();
|
||
delete ending2;
|
||
resource->free();
|
||
}
|
||
|
||
// Ejecuta la seccion del final de la partida
|
||
void Director::runGameOver()
|
||
{
|
||
if (options->console)
|
||
{
|
||
std::cout << "\n* SECTION: GAME OVER" << std::endl;
|
||
}
|
||
loadResources(section);
|
||
gameOver = new GameOver(renderer, screen, resource, asset, input, options, section);
|
||
gameOver->run();
|
||
delete gameOver;
|
||
resource->free();
|
||
}
|
||
|
||
// Ejecuta la seccion de juego donde se juega
|
||
void Director::runGame()
|
||
{
|
||
if (options->console)
|
||
{
|
||
std::cout << "\n* SECTION: GAME" << std::endl;
|
||
}
|
||
JA_StopMusic();
|
||
loadResources(section);
|
||
game = new Game(renderer, screen, resource, asset, online, options, input, section, debug);
|
||
game->run();
|
||
delete game;
|
||
resource->free();
|
||
}
|
||
|
||
void Director::run()
|
||
{
|
||
// Bucle principal
|
||
while (section->name != SECTION_PROG_QUIT)
|
||
{
|
||
switch (section->name)
|
||
{
|
||
case SECTION_PROG_LOGO:
|
||
runLogo();
|
||
break;
|
||
|
||
case SECTION_PROG_INTRO:
|
||
runIntro();
|
||
break;
|
||
|
||
case SECTION_PROG_TITLE:
|
||
runTitle();
|
||
break;
|
||
|
||
case SECTION_PROG_CREDITS:
|
||
runCredits();
|
||
break;
|
||
|
||
case SECTION_PROG_DEMO:
|
||
runDemo();
|
||
break;
|
||
|
||
case SECTION_PROG_GAME:
|
||
runGame();
|
||
break;
|
||
|
||
case SECTION_PROG_GAME_OVER:
|
||
runGameOver();
|
||
break;
|
||
|
||
case SECTION_PROG_ENDING:
|
||
runEnding();
|
||
break;
|
||
|
||
case SECTION_PROG_ENDING2:
|
||
runEnding2();
|
||
break;
|
||
}
|
||
}
|
||
} |