diff --git a/Makefile b/Makefile
index f716a7d..4ff491c 100644
--- a/Makefile
+++ b/Makefile
@@ -2,7 +2,7 @@ executable = jaildoctors_dilemma
source = source/*.cpp source/common/*.cpp
appName = JailDoctor's Dilemma
releaseFolder = jdd_release
-version = v1.07
+version = v1.08
# Release names
windowsRelease = $(executable)-$(version)-win32-x64.zip
diff --git a/README.md b/README.md
index e5e5d77..4454d08 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-# JailDoctor's Dilemma (v1.07)
+# JailDoctor's Dilemma (v1.08)
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.
diff --git a/release/Info.plist b/release/Info.plist
index 6cb6a36..0ac0347 100644
--- a/release/Info.plist
+++ b/release/Info.plist
@@ -23,11 +23,11 @@
CFBundlePackageType
APPL
CFBundleShortVersionString
- 1.0.7
+ 1.0.8
CFBundleSignature
????
CFBundleVersion
- 1.0.7
+ 1.0.8
CSResourcesFileMapped
LSMinimumSystemVersion
diff --git a/source/cheevos.cpp b/source/cheevos.cpp
index 91cc0e9..6efa055 100644
--- a/source/cheevos.cpp
+++ b/source/cheevos.cpp
@@ -1,13 +1,64 @@
#include "cheevos.h"
// Constructor
-Cheevos::Cheevos(options_t *options)
+Cheevos::Cheevos(Screen *screen, options_t *options)
{
+ // Copia la dirección de los objetos
this->options = options;
+ this->screen = screen;
+
+ // Inicializa los logros
+ init();
}
// Destructor
Cheevos::~Cheevos()
{
+ cheevos.clear();
+}
+// Inicializa los logros
+void Cheevos::init()
+{
+ cheevos_t c;
+ c.completed = false;
+
+ c.id = 1;
+ c.caption = "SALTA";
+ cheevos.push_back(c);
+
+ c.id = 2;
+ c.caption = "OBTEN 3 ITEMS";
+ cheevos.push_back(c);
+}
+
+// Busca un logro por id y devuelve el indice
+int Cheevos::findCheevo(int id)
+{
+ for (int i = 0; i < (int)cheevos.size(); ++i)
+ {
+ if (cheevos[i].id == id)
+ {
+ return i;
+ }
+ }
+
+ return -1;
+}
+
+// Desbloquea un logro
+void Cheevos::unlockCheevo(int id)
+{
+ const int index = findCheevo(id);
+
+ if (index == -1)
+ {
+ return;
+ }
+
+ if (!cheevos[index].completed)
+ {
+ cheevos[index].completed = true;
+ screen->showNotification(cheevos[index].caption);
+ }
}
\ No newline at end of file
diff --git a/source/cheevos.h b/source/cheevos.h
index d90fb95..3928533 100644
--- a/source/cheevos.h
+++ b/source/cheevos.h
@@ -1,5 +1,6 @@
#pragma once
#include
+#include "common/screen.h"
#include "common/utils.h"
#include
#include
@@ -7,21 +8,38 @@
#ifndef CHEEVOS_H
#define CHEEVOS_H
+struct cheevos_t
+{
+ int id; // Identificador del logro
+ std::string caption; // Texto que describe el logro
+ bool completed; // Indica si se ha obtenido el logro
+};
+
class Cheevos
{
private:
// Punteros y objetos
- options_t *options;
+ Screen *screen; // Objeto encargado de dibujar en pantalla
+ options_t *options; // Puntero a las opciones del juego
// Variables
+ std::vector cheevos; // Listado de logros
+ // Inicializa los logros
+ void init();
+
+ // Busca un logro por id y devuelve el indice
+ int findCheevo(int id);
public:
// Constructor
- Cheevos(options_t *options);
+ Cheevos(Screen *screen, options_t *options);
// Destructor
~Cheevos();
+
+ // Desbloquea un logro
+ void unlockCheevo(int id);
};
#endif
diff --git a/source/common/screen.cpp b/source/common/screen.cpp
index fcfc9f4..bfe7a96 100644
--- a/source/common/screen.cpp
+++ b/source/common/screen.cpp
@@ -383,9 +383,9 @@ void Screen::renderNotifications()
return;
}
- //SDL_RenderSetLogicalSize(renderer, notificationLogicalWidth, notificationLogicalHeight);
+ SDL_RenderSetLogicalSize(renderer, notificationLogicalWidth, notificationLogicalHeight);
notify->render();
- //SDL_RenderSetLogicalSize(renderer, windowWidth, windowHeight);
+ SDL_RenderSetLogicalSize(renderer, windowWidth, windowHeight);
}
// Establece el tamaño de las notificaciones
diff --git a/source/director.cpp b/source/director.cpp
index e0d7f8d..0741548 100644
--- a/source/director.cpp
+++ b/source/director.cpp
@@ -19,7 +19,7 @@ Director::Director(int argc, char *argv[])
section->subsection = SUBSECTION_LOGO_TO_INTRO;
#ifdef DEBUG
- section->name = SECTION_PROG_LOGO;
+ section->name = SECTION_PROG_GAME;
#endif
// Crea e inicializa las opciones del programa
diff --git a/source/game.cpp b/source/game.cpp
index 8368122..1ba13bc 100644
--- a/source/game.cpp
+++ b/source/game.cpp
@@ -4,13 +4,6 @@
// Constructor
Game::Game(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options, Input *input, section_t *section, Debug *debug)
{
- // Inicia algunas variables
- board.iniClock = SDL_GetTicks();
- currentRoom = "03.room";
- const int x = 25;
- const int y = 13;
- spawnPoint = {x * 8, y * 8, 0, 0, 0, s_standing, SDL_FLIP_HORIZONTAL};
-
// Copia los punteros
this->resource = resource;
this->renderer = renderer;
@@ -21,14 +14,22 @@ Game::Game(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *as
this->options = options;
this->section = section;
+ // Inicia algunas variables
+ board.iniClock = SDL_GetTicks();
#ifdef DEBUG
- currentRoom = "01.room";
- const int x1 = 25;
- const int y1 = 13;
- spawnPoint = {x1 * 8, y1 * 8, 0, 0, 0, s_standing, SDL_FLIP_HORIZONTAL};
+ currentRoom = "03.room";
+ const int x = 25;
+ const int y = 13;
+ spawnPoint = {x * 8, y * 8, 0, 0, 0, s_standing, SDL_FLIP_HORIZONTAL};
+#else
+ currentRoom = "03.room";
+ const int x = 25;
+ const int y = 13;
+ spawnPoint = {x * 8, y * 8, 0, 0, 0, s_standing, SDL_FLIP_HORIZONTAL};
#endif
// Crea los objetos
+ cheevos = new Cheevos(screen, options);
scoreboard = new ScoreBoard(renderer, resource, asset, options, &board);
itemTracker = new ItemTracker();
roomTracker = new RoomTracker();
@@ -89,6 +90,7 @@ Game::Game(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *as
Game::~Game()
{
// Libera la memoria de los objetos
+ delete cheevos;
delete scoreboard;
delete itemTracker;
delete roomTracker;
@@ -257,6 +259,7 @@ void Game::update()
checkGameOver();
checkEndGame();
checkRestoringJail();
+ checkSomeCheevos();
scoreboard->update();
input->update();
@@ -672,4 +675,13 @@ void Game::fillRoomNameTexture()
// Deja el renderizador por defecto
SDL_SetRenderTarget(renderer, nullptr);
+}
+
+// Comprueba algunos logros
+void Game::checkSomeCheevos()
+{
+ if (board.items == 1)
+ {
+ cheevos->unlockCheevo(2);
+ }
}
\ No newline at end of file
diff --git a/source/game.h b/source/game.h
index 6c274b5..33cfa49 100644
--- a/source/game.h
+++ b/source/game.h
@@ -1,6 +1,7 @@
#pragma once
#include
+#include "cheevos.h"
#include "common/animatedsprite.h"
#include "common/asset.h"
#include "common/debug.h"
@@ -37,6 +38,7 @@ private:
Input *input; // Objeto pata gestionar la entrada
Text *text; // Objeto para los textos del juego
ScoreBoard *scoreboard; // Objeto encargado de gestionar el marcador
+ Cheevos *cheevos; // Objeto encargado de gestionar los logros del juego
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
@@ -138,6 +140,9 @@ private:
// Pone el nombre de la habitación en la textura
void fillRoomNameTexture();
+ // Comprueba algunos logros
+ void checkSomeCheevos();
+
public:
// Constructor
Game(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options, Input *input, section_t *section, Debug *debug);