8 Commits

14 changed files with 111 additions and 50 deletions

View File

@@ -2,7 +2,7 @@ executable = jaildoctors_dilemma
source = source/*.cpp source/common/*.cpp
appName = JailDoctor's Dilemma
releaseFolder = jdd_release
version = v1.06.2
version = v1.07
# Release names
windowsRelease = $(executable)-$(version)-win32-x64.zip

View File

@@ -1,4 +1,4 @@
# JailDoctor's Dilemma (v1.06.2)
# JailDoctor's Dilemma (v1.07)
JailDoc es un Jailer. A los Jailers les gusta empezar proyectos. A nadie le gusta terminarlos. Los Jailers viven en la Jail. A la Jail va uno a empezar proyectos. A la Jail va uno a enseñar sus proyectos. A la Jail va uno a aprender como empezar nuevos proyectos. A la Jail va uno a ayudar a sus compañeros a que empiecen nuevos proyectos.

View File

@@ -3,9 +3,9 @@
<tileset firstgid="1" source="standard.tsx"/>
<layer id="1" name="Capa de patrones 1" width="32" height="16">
<data encoding="csv">
164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,
164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,43,43,43,43,43,43,43,43,43,43,43,43,43,43,164,
164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,
192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,
168,166,185,167,166,185,166,166,168,166,166,167,166,166,185,166,166,43,43,43,43,43,43,43,43,43,43,43,43,43,43,166,
211,181,211,213,211,181,211,212,213,211,181,211,211,212,211,213,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,
164,43,43,43,43,43,43,43,43,43,43,43,43,43,43,164,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,
43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,
43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,34,34,34,34,34,34,34,34,34,34,34,34,34,34,34,34,

View File

@@ -11,6 +11,22 @@ itemColor1=red
itemColor2=magenta
autoSurface=left
[enemy]
tileSetFile=batman_fire.png
animation=batman_fire.ani
width=16
height=16
x=10
y=13
vx=1.3
vy=0
x1=0
y1=13
x2=29
y2=13
color=cyan
flip=true
[/enemy]
[enemy]
tileSetFile=heavy.png

View File

@@ -23,11 +23,11 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0.6.2</string>
<string>1.0.7</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0.6.2</string>
<string>1.0.7</string>
<key>CSResourcesFileMapped</key>
<true/>
<key>LSMinimumSystemVersion</key>

View File

@@ -101,6 +101,7 @@ struct cheat_t
struct online_t
{
bool enabled; // Indica si se quiere usar el modo online o no
bool sessionEnabled; // Indica ya se ha hecho login
std::string server; // Servidor para los servicios online
int port; // Puerto del servidor
std::string gameID; // Identificador del juego para los servicios online

View File

@@ -40,7 +40,7 @@ Demo::Demo(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *as
board.lives = 9;
board.items = 0;
board.rooms = 1;
board.jailEnabled = options->cheat.jailEnabled;
board.jailEnabled = false;
board.music = true;
setScoreBoardColor();

View File

@@ -144,6 +144,7 @@ void Director::initOptions()
// Opciones online
options->online.enabled = true;
options->online.sessionEnabled = false;
options->online.server = "jaildoctor.duckdns.org";
options->online.port = 9911;
#ifdef DEBUG

View File

@@ -281,6 +281,11 @@ void EnterID::switchPalette()
// Inicializa los servicios online
void EnterID::initOnline()
{
if (options->online.sessionEnabled)
{ // Si ya ha iniciado la sesión, que no continue
return;
}
if (options->online.jailerID == "")
{ // Jailer ID no definido
@@ -289,10 +294,14 @@ void EnterID::initOnline()
else
{ // Jailer ID iniciado
options->online.enabled = true;
options->online.enabled = options->online.sessionEnabled = true;
jscore::init(options->online.server, options->online.port);
#ifdef DEBUG
const std::string caption = options->online.jailerID + " IS LOGGED IN (DEBUG)";
#else
const std::string caption = options->online.jailerID + " IS LOGGED IN";
#endif
screen->showNotification(caption);
if (options->console)
{

View File

@@ -42,6 +42,25 @@ Game::Game(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *as
deathSound = JA_LoadSound(asset->get("death.wav").c_str());
stats = new Stats(asset->get("stats.csv"), asset->get("stats_buffer.csv"), options);
// Crea la textura para poner el nombre de la habitación
roomNameTexture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, GAMECANVAS_WIDTH, text->getCharacterSize() * 2);
if (roomNameTexture == nullptr)
{
if (options->console)
{
std::cout << "Error: roomNameTexture could not be created!\nSDL Error: " << SDL_GetError() << std::endl;
}
}
// Establece el blend mode de la textura
SDL_SetTextureBlendMode(roomNameTexture, SDL_BLENDMODE_BLEND);
// Establece el destino de la textura
roomNameRect = {0, PLAY_AREA_HEIGHT, GAMECANVAS_WIDTH, text->getCharacterSize() * 2};
// Pone el nombre de la habitación en la textura
fillRoomNameTexture();
// Inicializa el resto de variables
ticks = 0;
ticksSpeed = 15;
@@ -78,6 +97,8 @@ Game::~Game()
delete text;
delete stats;
SDL_DestroyTexture(roomNameTexture);
JA_DeleteMusic(music);
JA_DeleteSound(deathSound);
}
@@ -317,13 +338,8 @@ void Game::renderDebugInfo()
// Escribe el nombre de la pantalla
void Game::renderRoomName()
{
// Texto en el centro de la pantalla
SDL_Rect rect = {0, 16 * BLOCK, PLAY_AREA_WIDTH, BLOCK * 2};
color_t color = stringToColor(options->palette, "white");
SDL_SetRenderDrawColor(renderer, color.r, color.g, color.b, 0xFF);
SDL_RenderFillRect(renderer, &rect);
text->writeDX(TXT_CENTER | TXT_COLOR, GAMECANVAS_CENTER_X, 16 * 8 + 4, room->getName(), 1, room->getBGColor());
// Dibuja la textura con el nombre de la habitación
SDL_RenderCopy(renderer, roomNameTexture, nullptr, &roomNameRect);
}
// Cambia de habitación
@@ -345,6 +361,9 @@ bool Game::changeRoom(std::string file)
// Crea un objeto habitación nuevo a partir del fichero
room = new Room(resource->getRoom(file), renderer, screen, asset, options, itemTracker, &board.items, board.jailEnabled, debug);
// Pone el nombre de la habitación en la textura
fillRoomNameTexture();
// Pone el color del marcador en función del color del borde de la habitación
setScoreBoardColor();
@@ -539,22 +558,16 @@ void Game::setScoreBoardColor()
// Comprueba si ha finalizado el juego
bool Game::checkEndGame()
{
const bool isOnTheRoom = room->getName() == "THE JAIL"; // Estar en la habitación que toca
const bool haveTheItems = board.items >= int(totalItems * 0.9f); // Con mas del 90% de los items recogidos
const bool isOnTheDoor = player->getRect().x <= 128; // Y en la ubicación que toca (En la puerta)
const bool isOnTheRoom = room->getName() == "THE JAIL"; // Estar en la habitación que toca
const bool haveTheItems = board.items >= int(totalItems * 0.9f) || options->cheat.jailEnabled; // Con mas del 90% de los items recogidos
const bool isOnTheDoor = player->getRect().x <= 128; // Y en la ubicación que toca (En la puerta)
if (haveTheItems)
{
board.jailEnabled = true;
}
if (isOnTheRoom && haveTheItems && isOnTheDoor)
{
section.name = SECTION_PROG_ENDING;
return true;
}
if (options->cheat.jailEnabled && isOnTheRoom && isOnTheDoor)
if (haveTheItems && isOnTheRoom && isOnTheDoor)
{
section.name = SECTION_PROG_ENDING;
return true;
@@ -642,4 +655,22 @@ void Game::initStats()
}
stats->init();
}
// Crea la textura con el nombre de la habitación
void Game::fillRoomNameTexture()
{
// Pone la textura como destino de renderizado
SDL_SetRenderTarget(renderer, roomNameTexture);
// Rellena la textura de color
const color_t color = stringToColor(options->palette, "white");
SDL_SetRenderDrawColor(renderer, color.r, color.g, color.b, 0xFF);
SDL_RenderClear(renderer);
// Escribe el texto en la textura
text->writeDX(TXT_CENTER | TXT_COLOR, GAMECANVAS_CENTER_X, text->getCharacterSize() / 2, room->getName(), 1, room->getBGColor());
// Deja el renderizador por defecto
SDL_SetRenderTarget(renderer, nullptr);
}

View File

@@ -26,35 +26,37 @@ class Game
{
private:
// Objetos y punteros
SDL_Renderer *renderer; // El renderizador de la ventana
SDL_Event *eventHandler; // Manejador de eventos
Screen *screen; // Objeto encargado de manejar el renderizador
Room *room; // Objeto encargado de gestionar cada habitación del juego
Player *player; // Objeto con el jugador
ItemTracker *itemTracker; // Lleva el control de los objetos recogidos
RoomTracker *roomTracker; // Lleva el control de las habitaciones visitadas
Asset *asset; // Objeto con la ruta a todos los ficheros de recursos
Input *input; // Objeto pata gestionar la entrada
Text *text; // Objeto para los textos del juego
ScoreBoard *scoreboard; // Objeto encargado de gestionar el marcador
Resource *resource; // Objeto con los recursos
Debug *debug; // Objeto para gestionar la información de debug
options_t *options; // Puntero a las opciones del juego
Stats *stats; // Objeto encargado de gestionar las estadísticas
SDL_Renderer *renderer; // El renderizador de la ventana
SDL_Event *eventHandler; // Manejador de eventos
Screen *screen; // Objeto encargado de manejar el renderizador
Room *room; // Objeto encargado de gestionar cada habitación del juego
Player *player; // Objeto con el jugador
ItemTracker *itemTracker; // Lleva el control de los objetos recogidos
RoomTracker *roomTracker; // Lleva el control de las habitaciones visitadas
Asset *asset; // Objeto con la ruta a todos los ficheros de recursos
Input *input; // Objeto pata gestionar la entrada
Text *text; // Objeto para los textos del juego
ScoreBoard *scoreboard; // Objeto encargado de gestionar el marcador
Resource *resource; // Objeto con los recursos
Debug *debug; // Objeto para gestionar la información de debug
options_t *options; // Puntero a las opciones del juego
Stats *stats; // Objeto encargado de gestionar las estadísticas
SDL_Texture *roomNameTexture; // Textura para escribir el nombre de la habitación
// Variables
JA_Music_t* music; // Musica que suena durante el juego
JA_Music_t *music; // Musica que suena durante el juego
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
section_t section; // Seccion actual dentro del juego
std::string currentRoom; // Fichero de la habitación actual
playerSpawn_t spawnPoint; // Lugar de la habitación donde aparece el jugador
JA_Sound_t* deathSound; // Sonido a reproducir cuando muere el jugador
JA_Sound_t *deathSound; // Sonido a reproducir cuando muere el jugador
board_t board; // Estructura con los datos del marcador
bool paused; // Indica si el juego se encuentra en pausa
bool blackScreen; // Indica si la pantalla está en negro. Se utiliza para la muerte del jugador
int blackScreenCounter; // Contador para temporizar la pantalla en negro
int totalItems; // Cantidad total de items que hay en el mapeado del juego
SDL_Rect roomNameRect; // Rectangulo donde pintar la textura con el nombre de la habitación
// Actualiza el juego, las variables, comprueba la entrada, etc.
void update();
@@ -133,6 +135,9 @@ private:
// Inicializa el diccionario de las estadísticas
void initStats();
// Pone el nombre de la habitación en la textura
void fillRoomNameTexture();
public:
// Constructor
Game(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options, Input *input, Debug *debug);

View File

@@ -126,7 +126,7 @@ void Intro::checkEventHandler()
break;
case SDL_SCANCODE_F5:
switchPalette();
//switchPalette();
break;
default:

View File

@@ -473,7 +473,7 @@ Room::Room(room_t *room, SDL_Renderer *renderer, Screen *screen, Asset *asset, o
setAnimatedTiles();
// Crea la textura para el mapa de tiles de la habitación
mapTexture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, GAMECANVAS_WIDTH, GAMECANVAS_HEIGHT);
mapTexture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, PLAY_AREA_WIDTH, PLAY_AREA_HEIGHT);
if (mapTexture == nullptr)
{
if (options->console)
@@ -665,7 +665,8 @@ void Room::fillMapTexture()
void Room::renderMap()
{
// Dibuja la textura con el mapa en pantalla
SDL_RenderCopy(renderer, mapTexture, nullptr, nullptr);
SDL_Rect dest = {0, 0, PLAY_AREA_WIDTH, PLAY_AREA_HEIGHT};
SDL_RenderCopy(renderer, mapTexture, nullptr, &dest);
// Dibuja los tiles animados
#ifdef DEBUG
@@ -1523,9 +1524,6 @@ void Room::openTheJail()
{
if (name == "THE JAIL")
{
// Cambia el color de fondo
bgColor = "red";
// Elimina el último enemigo (Bry debe ser el ultimo enemigo definido en el fichero)
delete enemies.back();
enemies.pop_back();

View File

@@ -104,7 +104,7 @@ private:
std::string tileMapFile; // Fichero con el mapa de indices de tile
std::vector<int> tileMap; // Indice de los tiles a dibujar en la habitación
int autoSurfaceDirection; // Sentido en el que arrastran las superficies automáticas de la habitación
JA_Sound_t* itemSound; // Sonido producido al coger un objeto
JA_Sound_t *itemSound; // Sonido producido al coger un objeto
std::vector<h_line_t> bottomSurfaces; // Lista con las superficies inferiores de la habitación
std::vector<h_line_t> topSurfaces; // Lista con las superficies superiores de la habitación
std::vector<v_line_t> leftSurfaces; // Lista con las superficies laterales de la parte izquierda de la habitación