Empezando a trabajar con los logros

This commit is contained in:
2022-12-29 09:09:36 +01:00
parent 8959b7bcce
commit a2f1efd2a6
9 changed files with 107 additions and 21 deletions

View File

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

View File

@@ -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. 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

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

View File

@@ -1,13 +1,64 @@
#include "cheevos.h" #include "cheevos.h"
// Constructor // Constructor
Cheevos::Cheevos(options_t *options) Cheevos::Cheevos(Screen *screen, options_t *options)
{ {
// Copia la dirección de los objetos
this->options = options; this->options = options;
this->screen = screen;
// Inicializa los logros
init();
} }
// Destructor // Destructor
Cheevos::~Cheevos() 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);
}
} }

View File

@@ -1,5 +1,6 @@
#pragma once #pragma once
#include <SDL2/SDL.h> #include <SDL2/SDL.h>
#include "common/screen.h"
#include "common/utils.h" #include "common/utils.h"
#include <string> #include <string>
#include <vector> #include <vector>
@@ -7,21 +8,38 @@
#ifndef CHEEVOS_H #ifndef CHEEVOS_H
#define 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 class Cheevos
{ {
private: private:
// Punteros y objetos // Punteros y objetos
options_t *options; Screen *screen; // Objeto encargado de dibujar en pantalla
options_t *options; // Puntero a las opciones del juego
// Variables // Variables
std::vector<cheevos_t> cheevos; // Listado de logros
// Inicializa los logros
void init();
// Busca un logro por id y devuelve el indice
int findCheevo(int id);
public: public:
// Constructor // Constructor
Cheevos(options_t *options); Cheevos(Screen *screen, options_t *options);
// Destructor // Destructor
~Cheevos(); ~Cheevos();
// Desbloquea un logro
void unlockCheevo(int id);
}; };
#endif #endif

View File

@@ -383,9 +383,9 @@ void Screen::renderNotifications()
return; return;
} }
//SDL_RenderSetLogicalSize(renderer, notificationLogicalWidth, notificationLogicalHeight); SDL_RenderSetLogicalSize(renderer, notificationLogicalWidth, notificationLogicalHeight);
notify->render(); notify->render();
//SDL_RenderSetLogicalSize(renderer, windowWidth, windowHeight); SDL_RenderSetLogicalSize(renderer, windowWidth, windowHeight);
} }
// Establece el tamaño de las notificaciones // Establece el tamaño de las notificaciones

View File

@@ -19,7 +19,7 @@ Director::Director(int argc, char *argv[])
section->subsection = SUBSECTION_LOGO_TO_INTRO; section->subsection = SUBSECTION_LOGO_TO_INTRO;
#ifdef DEBUG #ifdef DEBUG
section->name = SECTION_PROG_LOGO; section->name = SECTION_PROG_GAME;
#endif #endif
// Crea e inicializa las opciones del programa // Crea e inicializa las opciones del programa

View File

@@ -4,13 +4,6 @@
// Constructor // Constructor
Game::Game(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options, Input *input, section_t *section, Debug *debug) Game::Game(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 // Copia los punteros
this->resource = resource; this->resource = resource;
this->renderer = renderer; this->renderer = renderer;
@@ -21,14 +14,22 @@ Game::Game(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *as
this->options = options; this->options = options;
this->section = section; this->section = section;
// Inicia algunas variables
board.iniClock = SDL_GetTicks();
#ifdef DEBUG #ifdef DEBUG
currentRoom = "01.room"; currentRoom = "03.room";
const int x1 = 25; const int x = 25;
const int y1 = 13; const int y = 13;
spawnPoint = {x1 * 8, y1 * 8, 0, 0, 0, s_standing, SDL_FLIP_HORIZONTAL}; 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 #endif
// Crea los objetos // Crea los objetos
cheevos = new Cheevos(screen, options);
scoreboard = new ScoreBoard(renderer, resource, asset, options, &board); scoreboard = new ScoreBoard(renderer, resource, asset, options, &board);
itemTracker = new ItemTracker(); itemTracker = new ItemTracker();
roomTracker = new RoomTracker(); roomTracker = new RoomTracker();
@@ -89,6 +90,7 @@ Game::Game(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *as
Game::~Game() Game::~Game()
{ {
// Libera la memoria de los objetos // Libera la memoria de los objetos
delete cheevos;
delete scoreboard; delete scoreboard;
delete itemTracker; delete itemTracker;
delete roomTracker; delete roomTracker;
@@ -257,6 +259,7 @@ void Game::update()
checkGameOver(); checkGameOver();
checkEndGame(); checkEndGame();
checkRestoringJail(); checkRestoringJail();
checkSomeCheevos();
scoreboard->update(); scoreboard->update();
input->update(); input->update();
@@ -673,3 +676,12 @@ void Game::fillRoomNameTexture()
// Deja el renderizador por defecto // Deja el renderizador por defecto
SDL_SetRenderTarget(renderer, nullptr); SDL_SetRenderTarget(renderer, nullptr);
} }
// Comprueba algunos logros
void Game::checkSomeCheevos()
{
if (board.items == 1)
{
cheevos->unlockCheevo(2);
}
}

View File

@@ -1,6 +1,7 @@
#pragma once #pragma once
#include <SDL2/SDL.h> #include <SDL2/SDL.h>
#include "cheevos.h"
#include "common/animatedsprite.h" #include "common/animatedsprite.h"
#include "common/asset.h" #include "common/asset.h"
#include "common/debug.h" #include "common/debug.h"
@@ -37,6 +38,7 @@ private:
Input *input; // Objeto pata gestionar la entrada Input *input; // Objeto pata gestionar la entrada
Text *text; // Objeto para los textos del juego Text *text; // Objeto para los textos del juego
ScoreBoard *scoreboard; // Objeto encargado de gestionar el marcador ScoreBoard *scoreboard; // Objeto encargado de gestionar el marcador
Cheevos *cheevos; // Objeto encargado de gestionar los logros del juego
Resource *resource; // Objeto con los recursos Resource *resource; // Objeto con los recursos
Debug *debug; // Objeto para gestionar la información de debug Debug *debug; // Objeto para gestionar la información de debug
options_t *options; // Puntero a las opciones del juego options_t *options; // Puntero a las opciones del juego
@@ -138,6 +140,9 @@ private:
// Pone el nombre de la habitación en la textura // Pone el nombre de la habitación en la textura
void fillRoomNameTexture(); void fillRoomNameTexture();
// Comprueba algunos logros
void checkSomeCheevos();
public: public:
// Constructor // Constructor
Game(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options, Input *input, section_t *section, Debug *debug); Game(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options, Input *input, section_t *section, Debug *debug);