Compare commits
7 Commits
663e1ed32e
...
a05dbc7581
| Author | SHA1 | Date | |
|---|---|---|---|
| a05dbc7581 | |||
| 2db0b43d23 | |||
| d6c100379e | |||
| 22e8579337 | |||
| d0c0715640 | |||
| 38e0573a0e | |||
| f259fbb3a5 |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -11,4 +11,5 @@ thumbs.db
|
||||
*.zip
|
||||
*.app
|
||||
*_debug*
|
||||
sync_jail_engine.sh
|
||||
sync_jail_engine.sh
|
||||
jaildoctors_dilemma*
|
||||
@@ -138,6 +138,7 @@ void Cheevos::unlock(int id)
|
||||
|
||||
cheevos[index].completed = true;
|
||||
screen->showNotification("ACHIEVEMENT UNLOCKED!", cheevos[index].caption, cheevos[index].icon);
|
||||
saveToFile();
|
||||
}
|
||||
|
||||
// Invalida un logro
|
||||
@@ -239,4 +240,10 @@ void Cheevos::saveToFile()
|
||||
std::cout << "Error: Unable to save file! " << SDL_GetError() << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Lista los logros
|
||||
std::vector<cheevos_t> Cheevos::list()
|
||||
{
|
||||
return cheevos;
|
||||
}
|
||||
@@ -57,6 +57,9 @@ public:
|
||||
|
||||
// Habilita o deshabilita los logros
|
||||
void enable(bool value);
|
||||
|
||||
// Lista los logros
|
||||
std::vector<cheevos_t> list();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -501,6 +501,7 @@ void Director::loadResources(section_t *section)
|
||||
textureList.push_back("loading_screen_color_zxarne.png");
|
||||
textureList.push_back("smb2.png");
|
||||
textureList.push_back("debug.png");
|
||||
textureList.push_back("notify.png");
|
||||
|
||||
resource->loadTextures(textureList);
|
||||
|
||||
@@ -1219,18 +1220,25 @@ void Director::initInput()
|
||||
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
|
||||
|
||||
@@ -87,7 +87,6 @@ void Logo::checkEventHandler()
|
||||
// Comprueba las entradas
|
||||
void Logo::checkInput()
|
||||
{
|
||||
|
||||
if (input->checkInput(input_exit, REPEAT_FALSE))
|
||||
{
|
||||
section->name = SECTION_PROG_TITLE;
|
||||
|
||||
126
source/title.cpp
126
source/title.cpp
@@ -14,6 +14,7 @@ Title::Title(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *
|
||||
|
||||
// Reserva memoria para los punteros
|
||||
eventHandler = new SDL_Event();
|
||||
cheevos = new Cheevos(screen, options, asset->get("cheevos.bin"));
|
||||
if (options->palette == p_zxspectrum)
|
||||
{
|
||||
texture = resource->getTexture("loading_screen_color.png");
|
||||
@@ -32,23 +33,14 @@ Title::Title(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *
|
||||
section->subsection = 0;
|
||||
ticks = 0;
|
||||
ticksSpeed = 15;
|
||||
longText = "HEY JAILERS!! IT'S 2022 AND WE'RE STILL ROCKING LIKE IT'S 1998!!! HAVE YOU HEARD IT? JAILGAMES ARE BACK!! YEEESSS BACK!! MORE THAN 10 TITLES ON JAILDOC'S KITCHEN!! THATS A LOOOOOOT OF JAILGAMES, BUT WHICH ONE WILL STRIKE FIRST? THERE IS ALSO A NEW DEVICE TO COME THAT WILL BLOW YOUR MIND WITH JAILGAMES ON THE GO: P.A.C.O. BUT WAIT! WHAT'S THAT BEAUTY I'M SEEING RIGHT OVER THERE?? OOOH THAT TINY MINIASCII IS PURE LOVE!! I WANT TO LICK EVERY BYTE OF IT!! OH SHIT! AND DON'T FORGET TO BRING BACK THOSE OLD AND FAT MS-DOS JAILGAMES TO GITHUB TO KEEP THEM ALIVE!! WHAT WILL BE THE NEXT JAILDOC RELEASE? WHAT WILL BE THE NEXT PROJECT TO COME ALIVE?? OH BABY WE DON'T KNOW BUT HERE YOU CAN FIND THE ANSWER, YOU JUST HAVE TO COMPLETE JAILDOCTOR'S DILEMMA ... COULD YOU?";
|
||||
for (int i = 0; i < (int)longText.length(); ++i)
|
||||
{
|
||||
letter_t l;
|
||||
l.letter = longText.substr(i, 1);
|
||||
l.x = 256;
|
||||
l.enabled = false;
|
||||
letters.push_back(l);
|
||||
}
|
||||
letters[0].enabled = true;
|
||||
marqueeSpeed = 3;
|
||||
initMarquee();
|
||||
|
||||
// Crea el cartel de PRESS ENTER
|
||||
// Crea el cartel de PRESS ENTER
|
||||
#ifdef GAME_CONSOLE
|
||||
const std::string caption = "PRESS START TO PLAY";
|
||||
const string caption = "PRESS START TO PLAY";
|
||||
#else
|
||||
const std::string caption = "PRESS ENTER TO PLAY";
|
||||
const string caption = "PRESS ENTER TO PLAY";
|
||||
#endif
|
||||
const color_t textColor = stringToColor(options->palette, "white");
|
||||
const color_t strokeColor = stringToColor(options->palette, "bright_blue");
|
||||
@@ -63,6 +55,46 @@ Title::Title(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *
|
||||
// Crea el sprite
|
||||
pressEnterSprite = new Sprite(128 - (pressEnterTexture->getWidth() / 2), 192 / 5 * 4, pressEnterTexture->getWidth(), pressEnterTexture->getHeight(), pressEnterTexture, renderer);
|
||||
|
||||
// Crea la textura con el listado de logros
|
||||
const vector<cheevos_t> cheevosList = cheevos->list();
|
||||
const int iconSize = 16; // Altura del icono que representa a cada logro
|
||||
const int cheevoHeight = iconSize + 2; // EL espacio que ocupa cada logro es igual a la altura del icono mas dos pixeles de separación
|
||||
cheevosTexture = new Texture(renderer);
|
||||
cheevosTexture->createBlank(renderer, GAMECANVAS_WIDTH - 8, cheevoHeight * cheevosList.size(), SDL_TEXTUREACCESS_TARGET);
|
||||
cheevosTexture->setAsRenderTarget(renderer);
|
||||
cheevosTexture->setBlendMode(SDL_BLENDMODE_BLEND);
|
||||
const color_t cheevosBGColor = stringToColor(options->palette, "blue");
|
||||
SDL_SetRenderDrawColor(renderer, cheevosBGColor.r, cheevosBGColor.g, cheevosBGColor.b, 0xFF);
|
||||
SDL_RenderClear(renderer);
|
||||
infoText->writeDX(TXT_CENTER | TXT_COLOR, cheevosTexture->getWidth() / 2, 2, "ACHIEVEMENTS (0 / 12)", 1, stringToColor(options->palette, "bright_white"));
|
||||
int pos = 9;
|
||||
const color_t cheevoLockedColor = stringToColor(options->palette, "white");
|
||||
const color_t cheevoUnlockedColor = stringToColor(options->palette, "bright_white");
|
||||
color_t cheevoColor;
|
||||
|
||||
Texture *iconTexture = new Texture(renderer, asset->get("notify.png"));
|
||||
Sprite *sp = new Sprite({0, 0, iconSize, iconSize}, iconTexture, renderer);
|
||||
for (auto cheevo : cheevosList)
|
||||
{
|
||||
cheevoColor = cheevo.completed ? cheevoUnlockedColor : cheevoLockedColor;
|
||||
sp->setPos({2, pos, iconSize, iconSize});
|
||||
sp->setSpriteClip({iconSize * 2, 0, iconSize, iconSize});
|
||||
sp->getTexture()->setColor(cheevoColor.r, cheevoColor.g, cheevoColor.b);
|
||||
sp->render();
|
||||
pos += 2;
|
||||
infoText->writeColored(2 + iconSize + 2, pos, cheevo.caption, cheevoColor);
|
||||
pos += 6;
|
||||
infoText->writeColored(2 + iconSize + 2, pos, cheevo.description, cheevoColor);
|
||||
pos += 9;
|
||||
}
|
||||
delete sp;
|
||||
delete iconTexture;
|
||||
|
||||
// Crea el sprite para el listado de logros
|
||||
cheevosSprite = new Sprite(4, 4, cheevosTexture->getWidth(), cheevosTexture->getHeight(), cheevosTexture, renderer);
|
||||
cheevosTextureView = {0, 20, GAMECANVAS_WIDTH - 8, GAMECANVAS_HEIGHT - 8};
|
||||
cheevosSprite->setSpriteClip(cheevosTextureView);
|
||||
|
||||
// Cambia el color del borde
|
||||
screen->setBorderColor(stringToColor(options->palette, "bright_blue"));
|
||||
}
|
||||
@@ -70,14 +102,33 @@ Title::Title(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *
|
||||
// Destructor
|
||||
Title::~Title()
|
||||
{
|
||||
delete cheevos;
|
||||
delete eventHandler;
|
||||
delete sprite;
|
||||
delete pressEnterSprite;
|
||||
delete pressEnterTexture;
|
||||
delete cheevosSprite;
|
||||
delete cheevosTexture;
|
||||
delete text;
|
||||
delete infoText;
|
||||
}
|
||||
|
||||
// Inicializa la marquesina
|
||||
void Title::initMarquee()
|
||||
{
|
||||
letters.clear();
|
||||
longText = "HEY JAILERS!! IT'S 2022 AND WE'RE STILL ROCKING LIKE IT'S 1998!!! HAVE YOU HEARD IT? JAILGAMES ARE BACK!! YEEESSS BACK!! MORE THAN 10 TITLES ON JAILDOC'S KITCHEN!! THATS A LOOOOOOT OF JAILGAMES, BUT WHICH ONE WILL STRIKE FIRST? THERE IS ALSO A NEW DEVICE TO COME THAT WILL BLOW YOUR MIND WITH JAILGAMES ON THE GO: P.A.C.O. BUT WAIT! WHAT'S THAT BEAUTY I'M SEEING RIGHT OVER THERE?? OOOH THAT TINY MINIASCII IS PURE LOVE!! I WANT TO LICK EVERY BYTE OF IT!! OH SHIT! AND DON'T FORGET TO BRING BACK THOSE OLD AND FAT MS-DOS JAILGAMES TO GITHUB TO KEEP THEM ALIVE!! WHAT WILL BE THE NEXT JAILDOC RELEASE? WHAT WILL BE THE NEXT PROJECT TO COME ALIVE?? OH BABY WE DON'T KNOW BUT HERE YOU CAN FIND THE ANSWER, YOU JUST HAVE TO COMPLETE JAILDOCTOR'S DILEMMA ... COULD YOU?";
|
||||
for (int i = 0; i < (int)longText.length(); ++i)
|
||||
{
|
||||
letter_t l;
|
||||
l.letter = longText.substr(i, 1);
|
||||
l.x = 256;
|
||||
l.enabled = false;
|
||||
letters.push_back(l);
|
||||
}
|
||||
letters[0].enabled = true;
|
||||
}
|
||||
|
||||
// Comprueba el manejador de eventos
|
||||
void Title::checkEventHandler()
|
||||
{
|
||||
@@ -90,12 +141,41 @@ void Title::checkEventHandler()
|
||||
section->name = SECTION_PROG_QUIT;
|
||||
break;
|
||||
}
|
||||
if (eventHandler->type == SDL_KEYDOWN)
|
||||
{
|
||||
switch (eventHandler->key.keysym.scancode)
|
||||
{
|
||||
case SDL_SCANCODE_A:
|
||||
showCheevos = !showCheevos;
|
||||
break;
|
||||
|
||||
case SDL_SCANCODE_Z:
|
||||
initMarquee();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Comprueba las entradas
|
||||
void Title::checkInput()
|
||||
{
|
||||
if (showCheevos)
|
||||
{
|
||||
if (input->checkInput(input_down, REPEAT_TRUE))
|
||||
{
|
||||
cheevosTextureView.y++;
|
||||
cheevosSprite->setSpriteClip(cheevosTextureView);
|
||||
}
|
||||
else if (input->checkInput(input_up, REPEAT_TRUE))
|
||||
{
|
||||
cheevosTextureView.y--;
|
||||
cheevosSprite->setSpriteClip(cheevosTextureView);
|
||||
}
|
||||
}
|
||||
|
||||
if (input->checkInput(input_exit, REPEAT_FALSE))
|
||||
{
|
||||
@@ -177,7 +257,7 @@ void Title::renderMarquee()
|
||||
// Dibuja la linea de información inferior
|
||||
void Title::renderInfo()
|
||||
{
|
||||
const std::string loginText = options->online.enabled ? "OnLine: " + options->online.jailerID : "OnLine: OFF";
|
||||
const string loginText = options->online.enabled ? "OnLine: " + options->online.jailerID : "OnLine: OFF";
|
||||
infoText->writeDX(TXT_CENTER | TXT_COLOR, GAMECANVAS_FIRST_QUARTER_X, 1, loginText, 1, stringToColor(options->palette, "white"));
|
||||
infoText->writeDX(TXT_CENTER | TXT_COLOR, GAMECANVAS_CENTER_X, 1, "H: Help", 1, stringToColor(options->palette, "white"));
|
||||
infoText->writeDX(TXT_CENTER | TXT_COLOR, GAMECANVAS_THIRD_QUARTER_X, 1, "A: Achievements", 1, stringToColor(options->palette, "white"));
|
||||
@@ -210,8 +290,16 @@ void Title::update()
|
||||
// Comprueba si ha terminado la marquesina y acaba con el titulo
|
||||
if (letters[letters.size() - 1].x < -10)
|
||||
{
|
||||
section->name = SECTION_PROG_CREDITS;
|
||||
section->subsection = 0;
|
||||
if (!showCheevos)
|
||||
{
|
||||
section->name = SECTION_PROG_CREDITS;
|
||||
section->subsection = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Inicializa la marquesina
|
||||
initMarquee();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -237,6 +325,12 @@ void Title::render()
|
||||
// Dibuja la linea de información inferior
|
||||
renderInfo();
|
||||
|
||||
// Dibuja la información de logros
|
||||
if (showCheevos)
|
||||
{
|
||||
cheevosSprite->render();
|
||||
}
|
||||
|
||||
// Vuelca el contenido del renderizador en pantalla
|
||||
screen->blit();
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <SDL2/SDL.h>
|
||||
#include "cheevos.h"
|
||||
#include "jail_engine/asset.h"
|
||||
#include "jail_engine/input.h"
|
||||
#include "jail_engine/jail_audio.h"
|
||||
@@ -15,14 +16,16 @@
|
||||
#ifndef TITLE_H
|
||||
#define TITLE_H
|
||||
|
||||
using namespace std;
|
||||
|
||||
class Title
|
||||
{
|
||||
private:
|
||||
struct letter_t
|
||||
{
|
||||
std::string letter; // Letra a escribir
|
||||
int x; // Posición en el eje x
|
||||
bool enabled; // Solo se escriben y mueven si estan habilitadas
|
||||
string letter; // Letra a escribir
|
||||
int x; // Posición en el eje x
|
||||
bool enabled; // Solo se escriben y mueven si estan habilitadas
|
||||
};
|
||||
|
||||
// Objetos y punteros
|
||||
@@ -39,15 +42,20 @@ private:
|
||||
options_t *options; // Puntero a las opciones del juego
|
||||
Texture *pressEnterTexture; // Textura con los graficos de PRESS ENTER
|
||||
Sprite *pressEnterSprite; // Sprite para manejar la textura de PRESS ENTER
|
||||
Texture *cheevosTexture; // Textura con lo lista de logros
|
||||
Sprite *cheevosSprite; // Sprite para manejar la textura con la lista de logros
|
||||
Cheevos *cheevos; // Objeto encargado de gestionar los logros del juego
|
||||
section_t *section; // Estado del bucle principal para saber si continua o se sale
|
||||
|
||||
// Variables
|
||||
int counter; // Contador
|
||||
std::string longText; // Texto que aparece en la parte inferior del titulo
|
||||
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
|
||||
Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
|
||||
std::vector<letter_t> letters; // Vector con las letras de la marquesina
|
||||
int marqueeSpeed; // Velocidad de desplazamiento de la marquesina
|
||||
int counter; // Contador
|
||||
string longText; // Texto que aparece en la parte inferior del titulo
|
||||
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
|
||||
Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
|
||||
vector<letter_t> letters; // Vector con las letras de la marquesina
|
||||
int marqueeSpeed; // Velocidad de desplazamiento de la marquesina
|
||||
bool showCheevos; // Indica si se muestra por pantalla el listado de logros
|
||||
SDL_Rect cheevosTextureView; // Zona visible de la textura con el listado de logros
|
||||
|
||||
// Actualiza las variables
|
||||
void update();
|
||||
@@ -61,6 +69,9 @@ private:
|
||||
// Comprueba las entradas
|
||||
void checkInput();
|
||||
|
||||
// Inicializa la marquesina
|
||||
void initMarquee();
|
||||
|
||||
// Actualiza la marquesina
|
||||
void updateMarquee();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user