forked from jaildesigner-jailgames/jaildoctors_dilemma
1454 lines
53 KiB
C++
1454 lines
53 KiB
C++
#include "director.h"
|
|
#include <SDL2/SDL.h> // Para SDL_Init, SDL_Quit, SDL_INIT_E...
|
|
#include <SDL2/SDL_audio.h> // Para AUDIO_S16
|
|
#include <SDL2/SDL_blendmode.h> // Para SDL_BLENDMODE_BLEND
|
|
#include <SDL2/SDL_error.h> // Para SDL_GetError
|
|
#include <SDL2/SDL_gamecontroller.h> // Para SDL_CONTROLLER_BUTTON_B, SDL_C...
|
|
#include <SDL2/SDL_hints.h> // Para SDL_SetHint, SDL_HINT_RENDER_D...
|
|
#include <SDL2/SDL_scancode.h> // Para SDL_SCANCODE_A, SDL_SCANCODE_E...
|
|
#include <SDL2/SDL_stdinc.h> // Para Uint32
|
|
#include <SDL2/SDL_timer.h> // Para SDL_GetTicks
|
|
#include <errno.h> // Para errno, EEXIST, EACCES, ENAMETO...
|
|
#include <stdio.h> // Para printf, perror
|
|
#include <string.h> // Para strcmp
|
|
#include <sys/stat.h> // Para mkdir, stat, S_IRWXU
|
|
#include <unistd.h> // Para getuid
|
|
#include <cstdlib> // Para exit, EXIT_FAILURE, srand
|
|
#include <fstream> // Para basic_ofstream, basic_ifstream
|
|
#include <iostream> // Para basic_ostream, operator<<, cout
|
|
#include <string> // Para basic_string, operator+, char_...
|
|
#include <vector> // Para vector
|
|
#include <memory> // Para std::make_unique
|
|
#include "asset.h" // Para Asset, assetType
|
|
#include "const.h" // Para Section::LOGO, Section::TITLE
|
|
#include "debug.h" // Para Debug
|
|
#include "credits.h" // Para Credits
|
|
#include "demo.h" // Para Demo
|
|
#include "ending.h" // Para Ending
|
|
#include "ending2.h" // Para Ending2
|
|
#include "game.h" // Para Game
|
|
#include "game_over.h" // Para GameOver
|
|
#include "loading_screen.h" // Para LoadingScreen
|
|
#include "logo.h" // Para Logo
|
|
#include "title.h" // Para Title
|
|
#include "input.h" // Para Input, inputs_e
|
|
#include "jail_audio.h" // Para JA_GetMusicState, JA_DeleteMusic
|
|
#include "resource.h" // Para Resource
|
|
#include "screen.h" // Para Screen, FILTER_NEAREST, FILTER...
|
|
#include "utils.h" // Para options_t, section_t, op_notif...
|
|
#include "notifier.h"
|
|
#include "options.h"
|
|
#include "cheevos.h"
|
|
|
|
#ifndef _WIN32
|
|
#include <pwd.h>
|
|
#endif
|
|
|
|
// Constructor
|
|
Director::Director(int argc, const char *argv[])
|
|
{
|
|
std::cout << "Game start" << std::endl;
|
|
|
|
// Crea e inicializa las opciones del programa
|
|
initOptions();
|
|
|
|
// Comprueba los parametros del programa
|
|
executable_path_ = 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
|
|
createSystemFolder("jailgames");
|
|
createSystemFolder("jailgames/jaildoctors_dilemma");
|
|
|
|
// Si falta algún fichero no inicia el programa
|
|
if (!setFileList())
|
|
{
|
|
exit(EXIT_FAILURE);
|
|
}
|
|
|
|
// Carga las opciones desde un fichero
|
|
loadOptionsFromFile(Asset::get()->get("config.txt"));
|
|
|
|
// Inicializa SDL
|
|
initSDL();
|
|
|
|
// Inicializa JailAudio
|
|
initJailAudio();
|
|
|
|
// Crea los objetos
|
|
Screen::init(window_, renderer_);
|
|
Screen::get()->setBorderColor(borderColor);
|
|
Resource::init();
|
|
Notifier::init(Asset::get()->get("notify.png"), Asset::get()->get("smb2.png"), Asset::get()->get("smb2.txt"), Asset::get()->get("notify.wav"));
|
|
Input::init(Asset::get()->get("gamecontrollerdb.txt"));
|
|
initInput();
|
|
Debug::init();
|
|
title_music_ = JA_LoadMusic(Asset::get()->get("title.ogg").c_str());
|
|
Cheevos::init(Asset::get()->get("cheevos.bin"));
|
|
}
|
|
|
|
Director::~Director()
|
|
{
|
|
// Guarda las opciones a un fichero
|
|
saveOptionsToFile(Asset::get()->get("config.txt"));
|
|
|
|
// Destruye los singletones
|
|
Asset::destroy();
|
|
Input::destroy();
|
|
Screen::destroy();
|
|
Notifier::destroy();
|
|
Debug::destroy();
|
|
Resource::destroy();
|
|
Cheevos::destroy();
|
|
|
|
JA_DeleteMusic(title_music_);
|
|
|
|
SDL_DestroyRenderer(renderer_);
|
|
SDL_DestroyWindow(window_);
|
|
SDL_Quit();
|
|
|
|
std::cout << "\nBye!" << std::endl;
|
|
}
|
|
|
|
// Comprueba los parametros del programa
|
|
std::string Director::checkProgramArguments(int argc, const char *argv[])
|
|
{
|
|
// Comprueba los 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.cheats.infinite_lives = Cheat::CheatState::ENABLED;
|
|
}
|
|
|
|
else if (strcmp(argv[i], "--invincible") == 0)
|
|
{
|
|
options.cheats.invincible = Cheat::CheatState::ENABLED;
|
|
;
|
|
}
|
|
|
|
else if (strcmp(argv[i], "--jailEnabled") == 0)
|
|
{
|
|
options.cheats.jail_is_open = Cheat::CheatState::ENABLED;
|
|
;
|
|
}
|
|
|
|
else if (strcmp(argv[i], "--altSkin") == 0)
|
|
{
|
|
options.cheats.alternate_skin = Cheat::CheatState::ENABLED;
|
|
;
|
|
}
|
|
}
|
|
|
|
return argv[0];
|
|
}
|
|
|
|
// Crea la carpeta del sistema donde guardar datos
|
|
void Director::createSystemFolder(const std::string &folder)
|
|
{
|
|
#ifdef _WIN32
|
|
system_folder_ = std::string(getenv("APPDATA")) + "/" + folder;
|
|
#elif __APPLE__
|
|
struct passwd *pw = getpwuid(getuid());
|
|
const char *homedir = pw->pw_dir;
|
|
system_folder_ = std::string(homedir) + "/Library/Application Support" + "/" + folder;
|
|
#elif __linux__
|
|
struct passwd *pw = getpwuid(getuid());
|
|
const char *homedir = pw->pw_dir;
|
|
system_folder_ = std::string(homedir) + "/.config/" + folder;
|
|
|
|
{
|
|
// Intenta crear ".config", per si no existeix
|
|
std::string config_base_folder = std::string(homedir) + "/.config";
|
|
int ret = mkdir(config_base_folder.c_str(), S_IRWXU);
|
|
if (ret == -1 && errno != EEXIST)
|
|
{
|
|
printf("ERROR CREATING CONFIG BASE FOLDER.");
|
|
exit(EXIT_FAILURE);
|
|
}
|
|
}
|
|
#endif
|
|
|
|
struct stat st = {0};
|
|
if (stat(system_folder_.c_str(), &st) == -1)
|
|
{
|
|
errno = 0;
|
|
#ifdef _WIN32
|
|
int ret = mkdir(system_folder_.c_str());
|
|
#else
|
|
int ret = mkdir(system_folder_.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(SectionState section)
|
|
{
|
|
if (options.console)
|
|
{
|
|
std::cout << "** LOAD RESOURCES" << std::endl;
|
|
}
|
|
|
|
if (options.section.section == Section::LOGO)
|
|
{
|
|
std::vector<std::string> textureList;
|
|
textureList.push_back("jailgames.png");
|
|
textureList.push_back("since_1998.png");
|
|
|
|
Resource::get()->loadTextures(textureList);
|
|
}
|
|
|
|
else if (options.section.section == Section::LOADING_SCREEN)
|
|
{
|
|
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::get()->loadTextures(textureList);
|
|
}
|
|
|
|
else if (options.section.section == Section::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");
|
|
textureList.push_back("title_logo.png");
|
|
|
|
Resource::get()->loadTextures(textureList);
|
|
|
|
// Offsets
|
|
std::vector<std::string> offsetsList;
|
|
offsetsList.push_back("smb2.txt");
|
|
offsetsList.push_back("subatomic.txt");
|
|
|
|
Resource::get()->loadOffsets(offsetsList);
|
|
}
|
|
|
|
else if (options.section.section == Section::CREDITS)
|
|
{
|
|
// Texturas
|
|
std::vector<std::string> textureList;
|
|
textureList.push_back("shine.png");
|
|
textureList.push_back("smb2.png");
|
|
|
|
Resource::get()->loadTextures(textureList);
|
|
|
|
// Animaciones
|
|
std::vector<std::string> animationList;
|
|
animationList.push_back("shine.ani");
|
|
|
|
Resource::get()->loadAnimations(animationList);
|
|
|
|
// Offsets
|
|
std::vector<std::string> offsetsList;
|
|
offsetsList.push_back("smb2.txt");
|
|
|
|
Resource::get()->loadOffsets(offsetsList);
|
|
}
|
|
|
|
else if (options.section.section == Section::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::get()->loadTextures(textureList);
|
|
|
|
// Offsets
|
|
std::vector<std::string> offsetsList;
|
|
offsetsList.push_back("smb2.txt");
|
|
|
|
Resource::get()->loadOffsets(offsetsList);
|
|
}
|
|
|
|
else if (options.section.section == Section::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::get()->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::get()->loadAnimations(animationList);
|
|
|
|
// Offsets
|
|
std::vector<std::string> offsetsList;
|
|
offsetsList.push_back("smb2.txt");
|
|
|
|
Resource::get()->loadOffsets(offsetsList);
|
|
}
|
|
|
|
else if (options.section.section == Section::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::get()->loadTextures(textureList);
|
|
|
|
// Animaciones
|
|
std::vector<std::string> animationList;
|
|
animationList.push_back("player_game_over.ani");
|
|
animationList.push_back("tv.ani");
|
|
|
|
Resource::get()->loadAnimations(animationList);
|
|
|
|
// Offsets
|
|
std::vector<std::string> offsetsList;
|
|
offsetsList.push_back("smb2.txt");
|
|
|
|
Resource::get()->loadOffsets(offsetsList);
|
|
}
|
|
|
|
else if (options.section.section == Section::GAME || options.section.section == Section::DEMO)
|
|
{
|
|
// Texturas
|
|
std::vector<std::string> textureList;
|
|
|
|
// Jugador
|
|
textureList.push_back(options.cheats.alternate_skin == Cheat::CheatState::ENABLED ? "player2.png" : "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::get()->loadTextures(textureList);
|
|
|
|
// Animaciones
|
|
std::vector<std::string> animationList;
|
|
|
|
// Jugador
|
|
animationList.push_back(options.cheats.alternate_skin == Cheat::CheatState::ENABLED ? "player2.ani" : "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::get()->loadAnimations(animationList);
|
|
|
|
// Offsets
|
|
std::vector<std::string> offsetsList;
|
|
offsetsList.push_back("smb2.txt");
|
|
offsetsList.push_back("debug.txt");
|
|
|
|
Resource::get()->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::get()->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::get()->loadRooms(roomList);
|
|
}
|
|
|
|
if (options.console)
|
|
{
|
|
std::cout << "** RESOURCES LOADED" << std::endl;
|
|
}
|
|
}
|
|
|
|
// Inicia las variables necesarias para arrancar el programa
|
|
void Director::initInput()
|
|
{
|
|
// Establece si ha de mostrar mensajes
|
|
Input::get()->setVerbose(options.console);
|
|
|
|
// Busca si hay un mando conectado
|
|
Input::get()->discoverGameController();
|
|
|
|
// Teclado - Movimiento
|
|
if (options.keys == ControlScheme::CURSOR)
|
|
{
|
|
Input::get()->bindKey(input_jump, SDL_SCANCODE_UP);
|
|
Input::get()->bindKey(input_left, SDL_SCANCODE_LEFT);
|
|
Input::get()->bindKey(input_right, SDL_SCANCODE_RIGHT);
|
|
Input::get()->bindKey(input_up, SDL_SCANCODE_UP);
|
|
Input::get()->bindKey(input_down, SDL_SCANCODE_DOWN);
|
|
}
|
|
else if (options.keys == ControlScheme::OPQA)
|
|
{
|
|
Input::get()->bindKey(input_jump, SDL_SCANCODE_Q);
|
|
Input::get()->bindKey(input_left, SDL_SCANCODE_O);
|
|
Input::get()->bindKey(input_right, SDL_SCANCODE_P);
|
|
Input::get()->bindKey(input_up, SDL_SCANCODE_Q);
|
|
Input::get()->bindKey(input_down, SDL_SCANCODE_A);
|
|
}
|
|
else if (options.keys == ControlScheme::WASD)
|
|
{
|
|
Input::get()->bindKey(input_jump, SDL_SCANCODE_W);
|
|
Input::get()->bindKey(input_left, SDL_SCANCODE_A);
|
|
Input::get()->bindKey(input_right, SDL_SCANCODE_D);
|
|
Input::get()->bindKey(input_up, SDL_SCANCODE_W);
|
|
Input::get()->bindKey(input_down, SDL_SCANCODE_S);
|
|
}
|
|
|
|
// Teclado - Otros
|
|
Input::get()->bindKey(input_accept, SDL_SCANCODE_RETURN);
|
|
Input::get()->bindKey(input_cancel, SDL_SCANCODE_ESCAPE);
|
|
Input::get()->bindKey(input_pause, SDL_SCANCODE_H);
|
|
Input::get()->bindKey(input_exit, SDL_SCANCODE_ESCAPE);
|
|
Input::get()->bindKey(input_window_dec_size, SDL_SCANCODE_F1);
|
|
Input::get()->bindKey(input_window_inc_size, SDL_SCANCODE_F2);
|
|
Input::get()->bindKey(input_toggle_videomode, SDL_SCANCODE_F3);
|
|
Input::get()->bindKey(input_toggle_shaders, SDL_SCANCODE_F4);
|
|
Input::get()->bindKey(input_toggle_palette, SDL_SCANCODE_F5);
|
|
Input::get()->bindKey(input_toggle_music, SDL_SCANCODE_M);
|
|
Input::get()->bindKey(input_toggle_border, SDL_SCANCODE_B);
|
|
|
|
// Mando - Movimiento
|
|
Input::get()->bindGameControllerButton(input_jump, SDL_CONTROLLER_BUTTON_B);
|
|
Input::get()->bindGameControllerButton(input_left, SDL_CONTROLLER_BUTTON_DPAD_LEFT);
|
|
Input::get()->bindGameControllerButton(input_right, SDL_CONTROLLER_BUTTON_DPAD_RIGHT);
|
|
|
|
// Mando - Otros
|
|
Input::get()->bindGameControllerButton(input_accept, SDL_CONTROLLER_BUTTON_B);
|
|
Input::get()->bindGameControllerButton(input_cancel, SDL_CONTROLLER_BUTTON_A);
|
|
#ifdef GAME_CONSOLE
|
|
Input::get()->bindGameControllerButton(input_pause, SDL_CONTROLLER_BUTTON_BACK);
|
|
Input::get()->bindGameControllerButton(input_exit, SDL_CONTROLLER_BUTTON_START);
|
|
#else
|
|
Input::get()->bindGameControllerButton(input_pause, SDL_CONTROLLER_BUTTON_START);
|
|
Input::get()->bindGameControllerButton(input_exit, SDL_CONTROLLER_BUTTON_BACK);
|
|
#endif
|
|
Input::get()->bindGameControllerButton(input_toggle_palette, SDL_CONTROLLER_BUTTON_LEFTSHOULDER);
|
|
Input::get()->bindGameControllerButton(input_toggle_music, SDL_CONTROLLER_BUTTON_RIGHTSHOULDER);
|
|
Input::get()->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_EVERYTHING) < 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(static_cast<int>(options.video.filter)).c_str()))
|
|
{
|
|
if (options.console)
|
|
{
|
|
std::cout << "Warning: Nearest texture filtering not enabled!\n";
|
|
}
|
|
}
|
|
|
|
// Activa el render OpenGL
|
|
if (!SDL_SetHint(SDL_HINT_RENDER_DRIVER, "opengl"))
|
|
{
|
|
std::cout << "Warning: opengl not enabled!\n";
|
|
}
|
|
|
|
// Crea la ventana
|
|
options.window.width = options.video.border.enabled ? options.game.width + options.video.border.width * 2 : options.game.width;
|
|
options.window.height = options.video.border.enabled ? options.game.height + options.video.border.height * 2 : options.game.height;
|
|
|
|
window_ = SDL_CreateWindow(WINDOW_CAPTION, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, options.window.width, options.window.height, SDL_WINDOW_HIDDEN);
|
|
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_ACCELERATED | SDL_RENDERER_TARGETTEXTURE;
|
|
if (options.video.vertical_sync)
|
|
{
|
|
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.game.width, options.game.height);
|
|
|
|
// 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::get()->add(prefix + "/data/font/smb2.png", t_font);
|
|
Asset::get()->add(prefix + "/data/font/smb2.txt", t_font);
|
|
Asset::get()->add(prefix + "/data/font/debug.png", t_font);
|
|
Asset::get()->add(prefix + "/data/font/debug.txt", t_font);
|
|
Asset::get()->add(prefix + "/data/font/gauntlet.png", t_font);
|
|
Asset::get()->add(prefix + "/data/font/gauntlet.txt", t_font);
|
|
Asset::get()->add(prefix + "/data/font/subatomic.png", t_font);
|
|
Asset::get()->add(prefix + "/data/font/subatomic.txt", t_font);
|
|
|
|
// Shaders
|
|
Asset::get()->add(prefix + "/data/shaders/crtpi_192.glsl", t_data);
|
|
Asset::get()->add(prefix + "/data/shaders/crtpi_240.glsl", t_data);
|
|
|
|
// Datos
|
|
Asset::get()->add(prefix + "/data/input/gamecontrollerdb.txt", t_data);
|
|
|
|
// Ficheros de sistema
|
|
Asset::get()->add(system_folder_ + "/config.txt", t_data, false, true);
|
|
Asset::get()->add(system_folder_ + "/stats_buffer.csv", t_data, false, true);
|
|
Asset::get()->add(system_folder_ + "/stats.csv", t_data, false, true);
|
|
Asset::get()->add(system_folder_ + "/cheevos.bin", t_data, false, true);
|
|
|
|
// Notificaciones
|
|
Asset::get()->add(prefix + "/data/notifications/notify.png", t_bitmap);
|
|
|
|
// Habitaciones
|
|
Asset::get()->add(prefix + "/data/room/01.room", t_room);
|
|
Asset::get()->add(prefix + "/data/room/02.room", t_room);
|
|
Asset::get()->add(prefix + "/data/room/03.room", t_room);
|
|
Asset::get()->add(prefix + "/data/room/04.room", t_room);
|
|
Asset::get()->add(prefix + "/data/room/05.room", t_room);
|
|
Asset::get()->add(prefix + "/data/room/06.room", t_room);
|
|
Asset::get()->add(prefix + "/data/room/07.room", t_room);
|
|
Asset::get()->add(prefix + "/data/room/08.room", t_room);
|
|
Asset::get()->add(prefix + "/data/room/09.room", t_room);
|
|
Asset::get()->add(prefix + "/data/room/10.room", t_room);
|
|
Asset::get()->add(prefix + "/data/room/11.room", t_room);
|
|
Asset::get()->add(prefix + "/data/room/12.room", t_room);
|
|
Asset::get()->add(prefix + "/data/room/13.room", t_room);
|
|
Asset::get()->add(prefix + "/data/room/14.room", t_room);
|
|
Asset::get()->add(prefix + "/data/room/15.room", t_room);
|
|
Asset::get()->add(prefix + "/data/room/16.room", t_room);
|
|
Asset::get()->add(prefix + "/data/room/17.room", t_room);
|
|
Asset::get()->add(prefix + "/data/room/18.room", t_room);
|
|
Asset::get()->add(prefix + "/data/room/19.room", t_room);
|
|
Asset::get()->add(prefix + "/data/room/20.room", t_room);
|
|
Asset::get()->add(prefix + "/data/room/21.room", t_room);
|
|
Asset::get()->add(prefix + "/data/room/22.room", t_room);
|
|
Asset::get()->add(prefix + "/data/room/23.room", t_room);
|
|
Asset::get()->add(prefix + "/data/room/24.room", t_room);
|
|
Asset::get()->add(prefix + "/data/room/25.room", t_room);
|
|
Asset::get()->add(prefix + "/data/room/26.room", t_room);
|
|
Asset::get()->add(prefix + "/data/room/27.room", t_room);
|
|
Asset::get()->add(prefix + "/data/room/28.room", t_room);
|
|
Asset::get()->add(prefix + "/data/room/29.room", t_room);
|
|
Asset::get()->add(prefix + "/data/room/30.room", t_room);
|
|
Asset::get()->add(prefix + "/data/room/31.room", t_room);
|
|
Asset::get()->add(prefix + "/data/room/32.room", t_room);
|
|
Asset::get()->add(prefix + "/data/room/33.room", t_room);
|
|
Asset::get()->add(prefix + "/data/room/34.room", t_room);
|
|
Asset::get()->add(prefix + "/data/room/35.room", t_room);
|
|
Asset::get()->add(prefix + "/data/room/36.room", t_room);
|
|
Asset::get()->add(prefix + "/data/room/37.room", t_room);
|
|
Asset::get()->add(prefix + "/data/room/38.room", t_room);
|
|
Asset::get()->add(prefix + "/data/room/39.room", t_room);
|
|
Asset::get()->add(prefix + "/data/room/40.room", t_room);
|
|
Asset::get()->add(prefix + "/data/room/41.room", t_room);
|
|
Asset::get()->add(prefix + "/data/room/42.room", t_room);
|
|
Asset::get()->add(prefix + "/data/room/43.room", t_room);
|
|
Asset::get()->add(prefix + "/data/room/44.room", t_room);
|
|
Asset::get()->add(prefix + "/data/room/45.room", t_room);
|
|
Asset::get()->add(prefix + "/data/room/46.room", t_room);
|
|
Asset::get()->add(prefix + "/data/room/47.room", t_room);
|
|
Asset::get()->add(prefix + "/data/room/48.room", t_room);
|
|
Asset::get()->add(prefix + "/data/room/49.room", t_room);
|
|
Asset::get()->add(prefix + "/data/room/50.room", t_room);
|
|
Asset::get()->add(prefix + "/data/room/51.room", t_room);
|
|
Asset::get()->add(prefix + "/data/room/52.room", t_room);
|
|
Asset::get()->add(prefix + "/data/room/53.room", t_room);
|
|
Asset::get()->add(prefix + "/data/room/54.room", t_room);
|
|
Asset::get()->add(prefix + "/data/room/55.room", t_room);
|
|
Asset::get()->add(prefix + "/data/room/56.room", t_room);
|
|
Asset::get()->add(prefix + "/data/room/57.room", t_room);
|
|
Asset::get()->add(prefix + "/data/room/58.room", t_room);
|
|
Asset::get()->add(prefix + "/data/room/59.room", t_room);
|
|
Asset::get()->add(prefix + "/data/room/60.room", t_room);
|
|
|
|
// Tilemaps
|
|
Asset::get()->add(prefix + "/data/room/01.tmx", t_room);
|
|
Asset::get()->add(prefix + "/data/room/02.tmx", t_room);
|
|
Asset::get()->add(prefix + "/data/room/03.tmx", t_room);
|
|
Asset::get()->add(prefix + "/data/room/04.tmx", t_room);
|
|
Asset::get()->add(prefix + "/data/room/05.tmx", t_room);
|
|
Asset::get()->add(prefix + "/data/room/06.tmx", t_room);
|
|
Asset::get()->add(prefix + "/data/room/07.tmx", t_room);
|
|
Asset::get()->add(prefix + "/data/room/08.tmx", t_room);
|
|
Asset::get()->add(prefix + "/data/room/09.tmx", t_room);
|
|
Asset::get()->add(prefix + "/data/room/10.tmx", t_room);
|
|
Asset::get()->add(prefix + "/data/room/11.tmx", t_room);
|
|
Asset::get()->add(prefix + "/data/room/12.tmx", t_room);
|
|
Asset::get()->add(prefix + "/data/room/13.tmx", t_room);
|
|
Asset::get()->add(prefix + "/data/room/14.tmx", t_room);
|
|
Asset::get()->add(prefix + "/data/room/15.tmx", t_room);
|
|
Asset::get()->add(prefix + "/data/room/16.tmx", t_room);
|
|
Asset::get()->add(prefix + "/data/room/17.tmx", t_room);
|
|
Asset::get()->add(prefix + "/data/room/18.tmx", t_room);
|
|
Asset::get()->add(prefix + "/data/room/19.tmx", t_room);
|
|
Asset::get()->add(prefix + "/data/room/20.tmx", t_room);
|
|
Asset::get()->add(prefix + "/data/room/21.tmx", t_room);
|
|
Asset::get()->add(prefix + "/data/room/22.tmx", t_room);
|
|
Asset::get()->add(prefix + "/data/room/23.tmx", t_room);
|
|
Asset::get()->add(prefix + "/data/room/24.tmx", t_room);
|
|
Asset::get()->add(prefix + "/data/room/25.tmx", t_room);
|
|
Asset::get()->add(prefix + "/data/room/26.tmx", t_room);
|
|
Asset::get()->add(prefix + "/data/room/27.tmx", t_room);
|
|
Asset::get()->add(prefix + "/data/room/28.tmx", t_room);
|
|
Asset::get()->add(prefix + "/data/room/29.tmx", t_room);
|
|
Asset::get()->add(prefix + "/data/room/30.tmx", t_room);
|
|
Asset::get()->add(prefix + "/data/room/31.tmx", t_room);
|
|
Asset::get()->add(prefix + "/data/room/32.tmx", t_room);
|
|
Asset::get()->add(prefix + "/data/room/33.tmx", t_room);
|
|
Asset::get()->add(prefix + "/data/room/34.tmx", t_room);
|
|
Asset::get()->add(prefix + "/data/room/35.tmx", t_room);
|
|
Asset::get()->add(prefix + "/data/room/36.tmx", t_room);
|
|
Asset::get()->add(prefix + "/data/room/37.tmx", t_room);
|
|
Asset::get()->add(prefix + "/data/room/38.tmx", t_room);
|
|
Asset::get()->add(prefix + "/data/room/39.tmx", t_room);
|
|
Asset::get()->add(prefix + "/data/room/40.tmx", t_room);
|
|
Asset::get()->add(prefix + "/data/room/41.tmx", t_room);
|
|
Asset::get()->add(prefix + "/data/room/42.tmx", t_room);
|
|
Asset::get()->add(prefix + "/data/room/43.tmx", t_room);
|
|
Asset::get()->add(prefix + "/data/room/44.tmx", t_room);
|
|
Asset::get()->add(prefix + "/data/room/45.tmx", t_room);
|
|
Asset::get()->add(prefix + "/data/room/46.tmx", t_room);
|
|
Asset::get()->add(prefix + "/data/room/47.tmx", t_room);
|
|
Asset::get()->add(prefix + "/data/room/48.tmx", t_room);
|
|
Asset::get()->add(prefix + "/data/room/49.tmx", t_room);
|
|
Asset::get()->add(prefix + "/data/room/50.tmx", t_room);
|
|
Asset::get()->add(prefix + "/data/room/51.tmx", t_room);
|
|
Asset::get()->add(prefix + "/data/room/52.tmx", t_room);
|
|
Asset::get()->add(prefix + "/data/room/53.tmx", t_room);
|
|
Asset::get()->add(prefix + "/data/room/54.tmx", t_room);
|
|
Asset::get()->add(prefix + "/data/room/55.tmx", t_room);
|
|
Asset::get()->add(prefix + "/data/room/56.tmx", t_room);
|
|
Asset::get()->add(prefix + "/data/room/57.tmx", t_room);
|
|
Asset::get()->add(prefix + "/data/room/58.tmx", t_room);
|
|
Asset::get()->add(prefix + "/data/room/59.tmx", t_room);
|
|
Asset::get()->add(prefix + "/data/room/60.tmx", t_room);
|
|
|
|
// Tilesets
|
|
Asset::get()->add(prefix + "/data/tilesets/standard.png", t_bitmap);
|
|
Asset::get()->add(prefix + "/data/tilesets/standard_zxarne.png", t_bitmap);
|
|
|
|
// Enemigos
|
|
Asset::get()->add(prefix + "/data/enemies/abad_bell.ani", t_data);
|
|
Asset::get()->add(prefix + "/data/enemies/abad_bell.png", t_bitmap);
|
|
Asset::get()->add(prefix + "/data/enemies/abad.ani", t_data);
|
|
Asset::get()->add(prefix + "/data/enemies/abad.png", t_bitmap);
|
|
Asset::get()->add(prefix + "/data/enemies/amstrad_cs.ani", t_data);
|
|
Asset::get()->add(prefix + "/data/enemies/amstrad_cs.png", t_bitmap);
|
|
Asset::get()->add(prefix + "/data/enemies/flying_arounder.ani", t_data);
|
|
Asset::get()->add(prefix + "/data/enemies/flying_arounder.png", t_bitmap);
|
|
Asset::get()->add(prefix + "/data/enemies/stopped_arounder.ani", t_data);
|
|
Asset::get()->add(prefix + "/data/enemies/stopped_arounder.png", t_bitmap);
|
|
Asset::get()->add(prefix + "/data/enemies/walking_arounder.ani", t_data);
|
|
Asset::get()->add(prefix + "/data/enemies/walking_arounder.png", t_bitmap);
|
|
Asset::get()->add(prefix + "/data/enemies/arounders_door.ani", t_data);
|
|
Asset::get()->add(prefix + "/data/enemies/arounders_door.png", t_bitmap);
|
|
Asset::get()->add(prefix + "/data/enemies/arounders_machine.ani", t_data);
|
|
Asset::get()->add(prefix + "/data/enemies/arounders_machine.png", t_bitmap);
|
|
Asset::get()->add(prefix + "/data/enemies/bat.ani", t_data);
|
|
Asset::get()->add(prefix + "/data/enemies/bat.png", t_bitmap);
|
|
Asset::get()->add(prefix + "/data/enemies/batman_bell.ani", t_data);
|
|
Asset::get()->add(prefix + "/data/enemies/batman_bell.png", t_bitmap);
|
|
Asset::get()->add(prefix + "/data/enemies/batman_fire.ani", t_data);
|
|
Asset::get()->add(prefix + "/data/enemies/batman_fire.png", t_bitmap);
|
|
Asset::get()->add(prefix + "/data/enemies/batman.ani", t_data);
|
|
Asset::get()->add(prefix + "/data/enemies/batman.png", t_bitmap);
|
|
Asset::get()->add(prefix + "/data/enemies/bell.ani", t_data);
|
|
Asset::get()->add(prefix + "/data/enemies/bell.png", t_bitmap);
|
|
Asset::get()->add(prefix + "/data/enemies/bin.ani", t_data);
|
|
Asset::get()->add(prefix + "/data/enemies/bin.png", t_bitmap);
|
|
Asset::get()->add(prefix + "/data/enemies/bird.ani", t_data);
|
|
Asset::get()->add(prefix + "/data/enemies/bird.png", t_bitmap);
|
|
Asset::get()->add(prefix + "/data/enemies/breakout.ani", t_data);
|
|
Asset::get()->add(prefix + "/data/enemies/breakout.png", t_bitmap);
|
|
Asset::get()->add(prefix + "/data/enemies/bry.ani", t_data);
|
|
Asset::get()->add(prefix + "/data/enemies/bry.png", t_bitmap);
|
|
Asset::get()->add(prefix + "/data/enemies/chip.ani", t_data);
|
|
Asset::get()->add(prefix + "/data/enemies/chip.png", t_bitmap);
|
|
Asset::get()->add(prefix + "/data/enemies/code.ani", t_data);
|
|
Asset::get()->add(prefix + "/data/enemies/code.png", t_bitmap);
|
|
Asset::get()->add(prefix + "/data/enemies/congo.ani", t_data);
|
|
Asset::get()->add(prefix + "/data/enemies/congo.png", t_bitmap);
|
|
Asset::get()->add(prefix + "/data/enemies/crosshair.ani", t_data);
|
|
Asset::get()->add(prefix + "/data/enemies/crosshair.png", t_bitmap);
|
|
Asset::get()->add(prefix + "/data/enemies/demon.ani", t_data);
|
|
Asset::get()->add(prefix + "/data/enemies/demon.png", t_bitmap);
|
|
Asset::get()->add(prefix + "/data/enemies/dimallas.ani", t_data);
|
|
Asset::get()->add(prefix + "/data/enemies/dimallas.png", t_bitmap);
|
|
Asset::get()->add(prefix + "/data/enemies/floppy.ani", t_data);
|
|
Asset::get()->add(prefix + "/data/enemies/floppy.png", t_bitmap);
|
|
Asset::get()->add(prefix + "/data/enemies/dong.ani", t_data);
|
|
Asset::get()->add(prefix + "/data/enemies/dong.png", t_bitmap);
|
|
Asset::get()->add(prefix + "/data/enemies/guitar.ani", t_data);
|
|
Asset::get()->add(prefix + "/data/enemies/guitar.png", t_bitmap);
|
|
Asset::get()->add(prefix + "/data/enemies/heavy.ani", t_data);
|
|
Asset::get()->add(prefix + "/data/enemies/heavy.png", t_bitmap);
|
|
Asset::get()->add(prefix + "/data/enemies/jailer_#1.ani", t_data);
|
|
Asset::get()->add(prefix + "/data/enemies/jailer_#1.png", t_bitmap);
|
|
Asset::get()->add(prefix + "/data/enemies/jailer_#2.ani", t_data);
|
|
Asset::get()->add(prefix + "/data/enemies/jailer_#2.png", t_bitmap);
|
|
Asset::get()->add(prefix + "/data/enemies/jailer_#3.ani", t_data);
|
|
Asset::get()->add(prefix + "/data/enemies/jailer_#3.png", t_bitmap);
|
|
Asset::get()->add(prefix + "/data/enemies/jailbattle_alien.ani", t_data);
|
|
Asset::get()->add(prefix + "/data/enemies/jailbattle_alien.png", t_bitmap);
|
|
Asset::get()->add(prefix + "/data/enemies/jailbattle_human.ani", t_data);
|
|
Asset::get()->add(prefix + "/data/enemies/jailbattle_human.png", t_bitmap);
|
|
Asset::get()->add(prefix + "/data/enemies/jeannine.ani", t_data);
|
|
Asset::get()->add(prefix + "/data/enemies/jeannine.png", t_bitmap);
|
|
Asset::get()->add(prefix + "/data/enemies/lamp.ani", t_data);
|
|
Asset::get()->add(prefix + "/data/enemies/lamp.png", t_bitmap);
|
|
Asset::get()->add(prefix + "/data/enemies/lord_abad.ani", t_data);
|
|
Asset::get()->add(prefix + "/data/enemies/lord_abad.png", t_bitmap);
|
|
Asset::get()->add(prefix + "/data/enemies/matatunos.ani", t_data);
|
|
Asset::get()->add(prefix + "/data/enemies/matatunos.png", t_bitmap);
|
|
Asset::get()->add(prefix + "/data/enemies/mummy.ani", t_data);
|
|
Asset::get()->add(prefix + "/data/enemies/mummy.png", t_bitmap);
|
|
Asset::get()->add(prefix + "/data/enemies/paco.ani", t_data);
|
|
Asset::get()->add(prefix + "/data/enemies/paco.png", t_bitmap);
|
|
Asset::get()->add(prefix + "/data/enemies/elsa.ani", t_data);
|
|
Asset::get()->add(prefix + "/data/enemies/elsa.png", t_bitmap);
|
|
Asset::get()->add(prefix + "/data/enemies/qvoid.ani", t_data);
|
|
Asset::get()->add(prefix + "/data/enemies/qvoid.png", t_bitmap);
|
|
Asset::get()->add(prefix + "/data/enemies/robot.ani", t_data);
|
|
Asset::get()->add(prefix + "/data/enemies/robot.png", t_bitmap);
|
|
Asset::get()->add(prefix + "/data/enemies/sam.ani", t_data);
|
|
Asset::get()->add(prefix + "/data/enemies/sam.png", t_bitmap);
|
|
Asset::get()->add(prefix + "/data/enemies/shock.ani", t_data);
|
|
Asset::get()->add(prefix + "/data/enemies/shock.png", t_bitmap);
|
|
Asset::get()->add(prefix + "/data/enemies/sigmasua.ani", t_data);
|
|
Asset::get()->add(prefix + "/data/enemies/sigmasua.png", t_bitmap);
|
|
Asset::get()->add(prefix + "/data/enemies/spark.ani", t_data);
|
|
Asset::get()->add(prefix + "/data/enemies/spark.png", t_bitmap);
|
|
Asset::get()->add(prefix + "/data/enemies/special/aerojailer.ani", t_data);
|
|
Asset::get()->add(prefix + "/data/enemies/special/aerojailer.png", t_bitmap);
|
|
Asset::get()->add(prefix + "/data/enemies/special/arounder.ani", t_data);
|
|
Asset::get()->add(prefix + "/data/enemies/special/arounder.png", t_bitmap);
|
|
Asset::get()->add(prefix + "/data/enemies/special/pepe_rosita_job.ani", t_data);
|
|
Asset::get()->add(prefix + "/data/enemies/special/pepe_rosita_job.png", t_bitmap);
|
|
Asset::get()->add(prefix + "/data/enemies/special/shooting_star.ani", t_data);
|
|
Asset::get()->add(prefix + "/data/enemies/special/shooting_star.png", t_bitmap);
|
|
Asset::get()->add(prefix + "/data/enemies/spider.ani", t_data);
|
|
Asset::get()->add(prefix + "/data/enemies/spider.png", t_bitmap);
|
|
Asset::get()->add(prefix + "/data/enemies/tree_thing.ani", t_data);
|
|
Asset::get()->add(prefix + "/data/enemies/tree_thing.png", t_bitmap);
|
|
Asset::get()->add(prefix + "/data/enemies/tuno.ani", t_data);
|
|
Asset::get()->add(prefix + "/data/enemies/tuno.png", t_bitmap);
|
|
Asset::get()->add(prefix + "/data/enemies/tv_panel.ani", t_data);
|
|
Asset::get()->add(prefix + "/data/enemies/tv_panel.png", t_bitmap);
|
|
Asset::get()->add(prefix + "/data/enemies/tv.ani", t_data);
|
|
Asset::get()->add(prefix + "/data/enemies/tv.png", t_bitmap);
|
|
Asset::get()->add(prefix + "/data/enemies/upv_student.ani", t_data);
|
|
Asset::get()->add(prefix + "/data/enemies/upv_student.png", t_bitmap);
|
|
Asset::get()->add(prefix + "/data/enemies/wave.ani", t_data);
|
|
Asset::get()->add(prefix + "/data/enemies/wave.png", t_bitmap);
|
|
Asset::get()->add(prefix + "/data/enemies/z80.ani", t_data);
|
|
Asset::get()->add(prefix + "/data/enemies/z80.png", t_bitmap);
|
|
|
|
// Jugador
|
|
Asset::get()->add(prefix + "/data/player/player.png", t_bitmap);
|
|
Asset::get()->add(prefix + "/data/player/player.ani", t_data);
|
|
Asset::get()->add(prefix + "/data/player/player2.png", t_bitmap);
|
|
Asset::get()->add(prefix + "/data/player/player2.ani", t_data);
|
|
Asset::get()->add(prefix + "/data/player/player_game_over.png", t_bitmap);
|
|
Asset::get()->add(prefix + "/data/player/player_game_over.ani", t_data);
|
|
|
|
// Items
|
|
Asset::get()->add(prefix + "/data/items/items.png", t_bitmap);
|
|
|
|
// Musicas
|
|
Asset::get()->add(prefix + "/data/music/title.ogg", t_music);
|
|
Asset::get()->add(prefix + "/data/music/game.ogg", t_music);
|
|
Asset::get()->add(prefix + "/data/music/loading_sound1.ogg", t_music);
|
|
Asset::get()->add(prefix + "/data/music/loading_sound2.ogg", t_music);
|
|
Asset::get()->add(prefix + "/data/music/loading_sound3.ogg", t_music);
|
|
Asset::get()->add(prefix + "/data/music/ending1.ogg", t_music);
|
|
Asset::get()->add(prefix + "/data/music/ending2.ogg", t_music);
|
|
Asset::get()->add(prefix + "/data/music/game_over.ogg", t_music);
|
|
|
|
// Efectos de sonido
|
|
Asset::get()->add(prefix + "/data/sound/item.wav", t_sound);
|
|
Asset::get()->add(prefix + "/data/sound/death.wav", t_sound);
|
|
Asset::get()->add(prefix + "/data/sound/jump1.wav", t_sound);
|
|
Asset::get()->add(prefix + "/data/sound/jump2.wav", t_sound);
|
|
Asset::get()->add(prefix + "/data/sound/jump3.wav", t_sound);
|
|
Asset::get()->add(prefix + "/data/sound/jump4.wav", t_sound);
|
|
Asset::get()->add(prefix + "/data/sound/jump5.wav", t_sound);
|
|
Asset::get()->add(prefix + "/data/sound/jump6.wav", t_sound);
|
|
Asset::get()->add(prefix + "/data/sound/jump7.wav", t_sound);
|
|
Asset::get()->add(prefix + "/data/sound/jump8.wav", t_sound);
|
|
Asset::get()->add(prefix + "/data/sound/jump9.wav", t_sound);
|
|
Asset::get()->add(prefix + "/data/sound/jump10.wav", t_sound);
|
|
Asset::get()->add(prefix + "/data/sound/jump11.wav", t_sound);
|
|
Asset::get()->add(prefix + "/data/sound/jump12.wav", t_sound);
|
|
Asset::get()->add(prefix + "/data/sound/jump13.wav", t_sound);
|
|
Asset::get()->add(prefix + "/data/sound/jump14.wav", t_sound);
|
|
Asset::get()->add(prefix + "/data/sound/jump15.wav", t_sound);
|
|
Asset::get()->add(prefix + "/data/sound/jump16.wav", t_sound);
|
|
Asset::get()->add(prefix + "/data/sound/jump17.wav", t_sound);
|
|
Asset::get()->add(prefix + "/data/sound/jump18.wav", t_sound);
|
|
Asset::get()->add(prefix + "/data/sound/jump19.wav", t_sound);
|
|
Asset::get()->add(prefix + "/data/sound/jump20.wav", t_sound);
|
|
Asset::get()->add(prefix + "/data/sound/jump21.wav", t_sound);
|
|
Asset::get()->add(prefix + "/data/sound/jump22.wav", t_sound);
|
|
Asset::get()->add(prefix + "/data/sound/jump23.wav", t_sound);
|
|
Asset::get()->add(prefix + "/data/sound/jump24.wav", t_sound);
|
|
Asset::get()->add(prefix + "/data/sound/notify.wav", t_sound);
|
|
|
|
// Logo
|
|
Asset::get()->add(prefix + "/data/logo/jailgames.png", t_bitmap);
|
|
Asset::get()->add(prefix + "/data/logo/since_1998.png", t_bitmap);
|
|
|
|
// Intro
|
|
Asset::get()->add(prefix + "/data/title/loading_screen_bn.png", t_bitmap);
|
|
Asset::get()->add(prefix + "/data/title/loading_screen_color.png", t_bitmap);
|
|
Asset::get()->add(prefix + "/data/title/loading_screen_bn_zxarne.png", t_bitmap);
|
|
Asset::get()->add(prefix + "/data/title/loading_screen_color_zxarne.png", t_bitmap);
|
|
Asset::get()->add(prefix + "/data/title/loading_screen_color.gif", t_bitmap);
|
|
Asset::get()->add(prefix + "/data/title/title_logo.png", t_bitmap);
|
|
|
|
// Ending
|
|
Asset::get()->add(prefix + "/data/ending/ending1.png", t_bitmap);
|
|
Asset::get()->add(prefix + "/data/ending/ending1_zxarne.png", t_bitmap);
|
|
Asset::get()->add(prefix + "/data/ending/ending2.png", t_bitmap);
|
|
Asset::get()->add(prefix + "/data/ending/ending2_zxarne.png", t_bitmap);
|
|
Asset::get()->add(prefix + "/data/ending/ending3.png", t_bitmap);
|
|
Asset::get()->add(prefix + "/data/ending/ending3_zxarne.png", t_bitmap);
|
|
Asset::get()->add(prefix + "/data/ending/ending4.png", t_bitmap);
|
|
Asset::get()->add(prefix + "/data/ending/ending4_zxarne.png", t_bitmap);
|
|
Asset::get()->add(prefix + "/data/ending/ending5.png", t_bitmap);
|
|
Asset::get()->add(prefix + "/data/ending/ending5_zxarne.png", t_bitmap);
|
|
|
|
// Credits
|
|
Asset::get()->add(prefix + "/data/credits/shine.png", t_bitmap);
|
|
Asset::get()->add(prefix + "/data/credits/shine.ani", t_bitmap);
|
|
|
|
return Asset::get()->check();
|
|
}
|
|
|
|
// Ejecuta la seccion de juego con el logo
|
|
void Director::runLogo()
|
|
{
|
|
if (options.console)
|
|
{
|
|
std::cout << "\n* SECTION: LOGO" << std::endl;
|
|
}
|
|
loadResources(options.section);
|
|
auto logo = std::make_unique<Logo>();
|
|
logo->run();
|
|
Resource::get()->free();
|
|
}
|
|
|
|
// Ejecuta la seccion de juego de la pantalla de carga
|
|
void Director::runLoadingScreen()
|
|
{
|
|
if (options.console)
|
|
{
|
|
std::cout << "\n* SECTION: INTRO" << std::endl;
|
|
}
|
|
loadResources(options.section);
|
|
auto loadingScreen = std::make_unique<LoadingScreen>();
|
|
loadingScreen->run();
|
|
Resource::get()->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(title_music_);
|
|
}
|
|
loadResources(options.section);
|
|
auto title = std::make_unique<Title>();
|
|
title->run();
|
|
Resource::get()->free();
|
|
}
|
|
|
|
// Ejecuta la seccion de los creditos del juego
|
|
void Director::runCredits()
|
|
{
|
|
if (options.console)
|
|
{
|
|
std::cout << "\n* SECTION: CREDITS" << std::endl;
|
|
}
|
|
loadResources(options.section);
|
|
auto credits = std::make_unique<Credits>();
|
|
credits->run();
|
|
Resource::get()->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(options.section);
|
|
auto demo = std::make_unique<Demo>();
|
|
demo->run();
|
|
Resource::get()->free();
|
|
}
|
|
|
|
// Ejecuta la seccion del final del juego
|
|
void Director::runEnding()
|
|
{
|
|
if (options.console)
|
|
{
|
|
std::cout << "\n* SECTION: ENDING" << std::endl;
|
|
}
|
|
loadResources(options.section);
|
|
auto ending = std::make_unique<Ending>();
|
|
ending->run();
|
|
Resource::get()->free();
|
|
}
|
|
|
|
// Ejecuta la seccion del final del juego
|
|
void Director::runEnding2()
|
|
{
|
|
if (options.console)
|
|
{
|
|
std::cout << "\n* SECTION: ENDING2" << std::endl;
|
|
}
|
|
loadResources(options.section);
|
|
auto ending2 = std::make_unique<Ending2>();
|
|
ending2->run();
|
|
Resource::get()->free();
|
|
}
|
|
|
|
// Ejecuta la seccion del final de la partida
|
|
void Director::runGameOver()
|
|
{
|
|
if (options.console)
|
|
{
|
|
std::cout << "\n* SECTION: GAME OVER" << std::endl;
|
|
}
|
|
loadResources(options.section);
|
|
auto gameOver = std::make_unique<GameOver>();
|
|
gameOver->run();
|
|
Resource::get()->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(options.section);
|
|
auto game = std::make_unique<Game>();
|
|
game->run();
|
|
Resource::get()->free();
|
|
}
|
|
|
|
int Director::run()
|
|
{
|
|
// Bucle principal
|
|
while (options.section.section != Section::QUIT)
|
|
{
|
|
switch (options.section.section)
|
|
{
|
|
case Section::LOGO:
|
|
runLogo();
|
|
break;
|
|
|
|
case Section::LOADING_SCREEN:
|
|
runLoadingScreen();
|
|
break;
|
|
|
|
case Section::TITLE:
|
|
runTitle();
|
|
break;
|
|
|
|
case Section::CREDITS:
|
|
runCredits();
|
|
break;
|
|
|
|
case Section::DEMO:
|
|
runDemo();
|
|
break;
|
|
|
|
case Section::GAME:
|
|
runGame();
|
|
break;
|
|
|
|
case Section::GAME_OVER:
|
|
runGameOver();
|
|
break;
|
|
|
|
case Section::ENDING:
|
|
runEnding();
|
|
break;
|
|
|
|
case Section::ENDING2:
|
|
runEnding2();
|
|
break;
|
|
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
|
|
return 0;
|
|
} |