Eliminat tot el online, jailerid, tables de puntuacions, etc..

Tots els fitxers cpp juntets
This commit is contained in:
2025-02-21 11:07:39 +01:00
parent 62a61ecad4
commit a08da3b983
60 changed files with 88 additions and 2110 deletions

View File

@@ -1,7 +1,7 @@
# CMakeLists.txt
cmake_minimum_required(VERSION 3.10)
project(coffee_crisis)
project(coffee_crisis VERSION 1.00)
# Configuración de compilador para MinGW en Windows, si es necesario
if(WIN32 AND NOT CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
@@ -10,7 +10,7 @@ if(WIN32 AND NOT CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
endif()
# Establecer estándar de C++
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED True)
# Configuración global de flags de compilación
@@ -20,8 +20,8 @@ set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Os -ffunction-sections
# Define el directorio de los archivos fuente
set(DIR_SOURCES "${CMAKE_SOURCE_DIR}/source")
# Cargar todos los archivos fuente en DIR_SOURCES de manera recursiva
file(GLOB_RECURSE SOURCES "${DIR_SOURCES}/*.cpp")
# Cargar todos los archivos fuente en DIR_SOURCES
file(GLOB SOURCES "${DIR_SOURCES}/*.cpp")
# Verificar si se encontraron archivos fuente
if(NOT SOURCES)
@@ -60,26 +60,12 @@ target_link_libraries(${PROJECT_NAME} ${LIBS})
# Configuración específica para cada plataforma
if(WIN32)
target_compile_definitions(${PROJECT_NAME} PRIVATE WINDOWS_BUILD)
target_link_libraries(${PROJECT_NAME} mingw32 opengl32 gdi32 winmm imm32 ole32 version)
target_link_libraries(${PROJECT_NAME} mingw32 gdi32 winmm imm32 ole32 version)
elseif(APPLE)
set(LIBS ${LIBS} "-framework OpenGL")
target_compile_definitions(${PROJECT_NAME} PRIVATE MACOS_BUILD)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated")
# Configurar compilación para Apple Silicon
set(CMAKE_OSX_ARCHITECTURES "arm64")
elseif(UNIX AND NOT APPLE)
set(LIBS ${LIBS} GL)
target_compile_definitions(${PROJECT_NAME} PRIVATE LINUX_BUILD)
target_link_libraries(${PROJECT_NAME} ${LIBS})
endif()
# Añadir OpenGL a las bibliotecas enlazadas
if(NOT WIN32)
find_package(OpenGL REQUIRED)
if(OPENGL_FOUND)
message(STATUS "OpenGL encontrado: ${OPENGL_LIBRARIES}")
target_link_libraries(${PROJECT_NAME} ${OPENGL_LIBRARIES})
else()
message(FATAL_ERROR "OpenGL no encontrado")
endif()
endif()

View File

@@ -1,5 +1,5 @@
executable = coffee_crisis
source = source/*.cpp source/common/*.cpp
source = source/*.cpp
appName = Coffee Crisis
releaseFolder = cc_release
version = v2.3.1

View File

@@ -101,18 +101,7 @@ line=true
[item]
text=HOW TO PLAY
hPaddingDown=2
[/item]
[item]
text=HISCORE TABLE
hPaddingDown=2
[/item]
[item]
text=JAILERID:
hPaddingDown=6
line=true
[/item]
[item]

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

View File

@@ -8,9 +8,6 @@
#include <string>
#include <vector>
#ifndef ANIMATEDSPRITE_H
#define ANIMATEDSPRITE_H
struct animation_t
{
std::string name; // Nombre de la animacion
@@ -99,5 +96,3 @@ public:
// Reinicia la animación
void resetAnimation();
};
#endif

View File

@@ -4,9 +4,6 @@
#include <string>
#include <vector>
#ifndef ASSET_H
#define ASSET_H
enum assetType
{
t_bitmap,
@@ -62,5 +59,3 @@ public:
// Establece si ha de mostrar texto por pantalla
void setVerbose(bool value);
};
#endif

View File

@@ -1,14 +1,11 @@
#pragma once
#include <SDL2/SDL.h>
#include "common/animatedsprite.h"
#include "common/utils.h"
#include "animatedsprite.h"
#include "utils.h"
#include <sstream>
#include <vector>
#ifndef BALLOON_H
#define BALLOON_H
// Cantidad de elementos del vector con los valores de la deformación del globo al rebotar
#define MAX_BOUNCE 10
@@ -250,5 +247,3 @@ public:
// Obtiene le valor de la variable
Uint8 getPower();
};
#endif

View File

@@ -1,11 +1,8 @@
#pragma once
#include <SDL2/SDL.h>
#include "common/sprite.h"
#include "common/utils.h"
#ifndef BULLET_H
#define BULLET_H
#include "sprite.h"
#include "utils.h"
// Tipos de bala
#define BULLET_UP 1
@@ -80,5 +77,3 @@ public:
// Obtiene el circulo de colisión
circle_t &getCollider();
};
#endif

View File

@@ -1,101 +0,0 @@
#ifdef JA_USESDLMIXER
#include "jail_audio.h"
#include <SDL2/SDL.h>
#include <SDL2/SDL_mixer.h>
#include <stdio.h>
struct JA_Sound_t {}; // Dummy structs
struct JA_Music_t {};
int JA_freq {48000};
SDL_AudioFormat JA_format {AUDIO_S16};
Uint8 JA_channels {2};
void JA_Init(const int freq, const SDL_AudioFormat format, const int channels) {
JA_freq = freq;
JA_format = format;
JA_channels = channels;
Mix_OpenAudio(JA_freq, JA_format, JA_channels, 1024);
}
void JA_Quit() {
Mix_CloseAudio();
}
JA_Music_t *JA_LoadMusic(const char* filename) {
return (JA_Music_t*)Mix_LoadMUS(filename);
}
void JA_PlayMusic(JA_Music_t *music, const int loop) {
Mix_PlayMusic((Mix_Music*)music, loop);
}
void JA_PauseMusic() {
Mix_PauseMusic();
}
void JA_ResumeMusic() {
Mix_ResumeMusic();
}
void JA_StopMusic() {
Mix_HaltMusic();
}
JA_Music_state JA_GetMusicState() {
if (Mix_PausedMusic()) {
return JA_MUSIC_PAUSED;
} else if (Mix_PlayingMusic()) {
return JA_MUSIC_PLAYING;
} else {
return JA_MUSIC_STOPPED;
}
}
void JA_DeleteMusic(JA_Music_t *music) {
Mix_FreeMusic((Mix_Music*)music);
}
JA_Sound_t *JA_NewSound(Uint8* buffer, Uint32 length) {
return NULL;
}
JA_Sound_t *JA_LoadSound(const char* filename) {
JA_Sound_t *sound = (JA_Sound_t*)Mix_LoadWAV(filename);
return sound;
}
int JA_PlaySound(JA_Sound_t *sound, const int loop) {
return Mix_PlayChannel(-1, (Mix_Chunk*)sound, loop);
}
void JA_DeleteSound(JA_Sound_t *sound) {
Mix_FreeChunk((Mix_Chunk*)sound);
}
void JA_PauseChannel(const int channel) {
Mix_Pause(channel);
}
void JA_ResumeChannel(const int channel) {
Mix_Resume(channel);
}
void JA_StopChannel(const int channel) {
Mix_HaltChannel(channel);
}
JA_Channel_state JA_GetChannelState(const int channel) {
if (Mix_Paused(channel)) {
return JA_CHANNEL_PAUSED;
} else if (Mix_Playing(channel)) {
return JA_CHANNEL_PLAYING;
} else {
return JA_CHANNEL_FREE;
}
}
int JA_SetVolume(int volume) {
return Mix_Volume(-1, volume);
}
#endif

View File

@@ -1,154 +0,0 @@
#include "jscore.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#ifdef _WIN32
#include <winsock2.h>
#else
#include <sys/socket.h>
#include <netdb.h>
#include <netinet/in.h>
#endif
#include <unistd.h>
#include <string>
#include <vector>
namespace jscore {
using namespace std;
struct user {
string name;
int points;
};
vector<user> score;
#define bzero(b,len) (memset((b), '\0', (len)), (void) 0)
int sock;
struct sockaddr_in client;
int PORT = 9911;
string HOST = "jaildoctor.duckdns.org";
#ifdef WIN32
WSADATA WsaData;
#endif
bool jscore_error = false;
string error_message;
void init(std::string host, const int port) {
PORT = port;
HOST = host;
}
void setErrorMessage(string message) {
jscore_error = true;
error_message = message;
}
string sendRequest(const string request) {
#ifdef WIN32
int ret = WSAStartup(0x101,&WsaData);
if (ret != 0) return 0;
#endif
struct hostent * host = gethostbyname(HOST.c_str());
if ( (host == NULL) || (host->h_addr == NULL) ) {
setErrorMessage("Error retrieving DNS information.\n");
return "";
}
bzero(&client, sizeof(client));
client.sin_family = AF_INET;
client.sin_port = htons( PORT );
memcpy(&client.sin_addr, host->h_addr, host->h_length);
sock = socket(AF_INET, SOCK_STREAM, 0);
if (sock < 0) {
setErrorMessage("Error creating socket.\n");
return "";
}
if ( connect(sock, (struct sockaddr *)&client, sizeof(client)) < 0 ) {
close(sock);
setErrorMessage("Could not connect\n");
return "";
}
string r = request + " HTTP/1.1\r\nHost: "+HOST+"\r\nConnection: close\r\n\r\n\r\n";
if (send(sock, r.c_str(), r.length(), 0) != (int)r.length()) {
setErrorMessage("Error sending request.\n");
return "";
}
char cur;
char start[5]="\r\n\r\n";
int pos = 0;
while ( recv(sock, &cur, 1,0) > 0 ) {
if (cur==start[pos]) { pos++; if (pos == 4) break; } else { pos = 0; }
}
char buffer[1024]; buffer[0]=0; pos=0;
while ( recv(sock, &cur, 1,0) > 0 ) {
buffer[pos] = cur;
pos++;
}
#ifdef WIN32
WSACleanup();
#endif
buffer[pos]=0;
return buffer;
}
const bool initOnlineScore(string game) {
string strbuff = sendRequest("GET /score-list.php?game=" + game);
if (jscore_error) return not jscore_error;
user u;
char buffer[1024];
strcpy(buffer, strbuff.c_str());
char *str = buffer;
char *p = str;
score.clear();
while (*p!=0) {
while (*p!=',') {p++;}
*p=0; u.name = str; p++; str=p;
while (*p!='\n') {p++;}
*p=0; u.points = atoi(str); p++; str=p;
score.push_back(u);
}
return not jscore_error;
}
const int getNumUsers() {
return score.size();
}
string getUserName(const int index) {
return score[index].name;
}
const int getPoints(const int index) {
return score[index].points;
}
const bool updateUserPoints(string game, string user, const int points) {
string strbuff = sendRequest("GET /score-update.php?game=" + game + "&user=" + user + "&points=" + to_string(points));
initOnlineScore(game);
return not jscore_error;
}
const int getUserPoints(string game, std::string user) {
return atoi(sendRequest("GET /getuserpoints.php?game=" + game + "&user=" + user).c_str());
}
string getUserData(string game, string user) {
return sendRequest("GET /getuserdata.php?game=" + game + "&user=" + user);
}
void setUserData(string game, string user, string data) {
sendRequest("GET /setuserdata.php?game=" + game + "&user=" + user + "&data=" + data);
}
};

View File

@@ -1,16 +0,0 @@
#pragma once
#include <string>
namespace jscore {
void init(std::string host, const int port);
const bool initOnlineScore(std::string game);
const int getNumUsers();
std::string getUserName(const int index);
const int getPoints(const int index);
const int getUserPoints(std::string game, std::string user);
const bool updateUserPoints(std::string game, std::string user, const int points);
std::string getUserData(std::string game, std::string user);
void setUserData(std::string game, std::string user, std::string data);
};

View File

@@ -1,285 +0,0 @@
#include "notify.h"
#include <string>
#include <stdio.h>
#include <iostream>
// Constructor
Notify::Notify(SDL_Renderer *renderer, std::string iconFile, std::string bitmapFile, std::string textFile, std::string soundFile, options_t *options)
{
// Inicializa variables
this->renderer = renderer;
this->options = options;
bgColor = options->notifications.color;
waitTime = 300;
// Crea objetos
iconTexture = new Texture(renderer, iconFile);
textTexture = new Texture(renderer, bitmapFile);
text = new Text(textFile, textTexture, renderer);
sound = JA_LoadSound(soundFile.c_str());
}
// Destructor
Notify::~Notify()
{
// Libera la memoria de los objetos
delete textTexture;
delete iconTexture;
delete text;
JA_DeleteSound(sound);
for (auto notification : notifications)
{
delete notification.sprite;
delete notification.texture;
}
}
// Dibuja las notificaciones por pantalla
void Notify::render()
{
for (int i = (int)notifications.size() - 1; i >= 0; --i)
{
notifications[i].sprite->render();
}
}
// Actualiza el estado de las notificaiones
void Notify::update()
{
for (int i = 0; i < (int)notifications.size(); ++i)
{
// Si la notificación anterior está "saliendo", no hagas nada
if (i > 0)
{
if (notifications[i - 1].state == ns_rising)
{
break;
}
}
notifications[i].counter++;
// Hace sonar la notificación en el primer frame
if (notifications[i].counter == 1)
{
if (options->notifications.sound)
{
if (notifications[i].state == ns_rising)
{ // Reproduce el sonido de la notificación
JA_PlaySound(sound);
}
}
}
// Comprueba los estados
if (notifications[i].state == ns_rising)
{
const float step = ((float)notifications[i].counter / notifications[i].travelDist);
const int alpha = 255 * step;
if (options->notifications.posV == pos_top)
{
notifications[i].rect.y++;
}
else
{
notifications[i].rect.y--;
}
notifications[i].texture->setAlpha(alpha);
if (notifications[i].rect.y == notifications[i].y)
{
notifications[i].state = ns_stay;
notifications[i].texture->setAlpha(255);
notifications[i].counter = 0;
}
}
else if (notifications[i].state == ns_stay)
{
if (notifications[i].counter == waitTime)
{
notifications[i].state = ns_vanishing;
notifications[i].counter = 0;
}
}
else if (notifications[i].state == ns_vanishing)
{
const float step = (notifications[i].counter / (float)notifications[i].travelDist);
const int alpha = 255 * (1 - step);
if (options->notifications.posV == pos_top)
{
notifications[i].rect.y--;
}
else
{
notifications[i].rect.y++;
}
notifications[i].texture->setAlpha(alpha);
if (notifications[i].rect.y == notifications[i].y - notifications[i].travelDist)
{
notifications[i].state = ns_finished;
}
}
notifications[i].sprite->setRect(notifications[i].rect);
}
clearFinishedNotifications();
}
// Elimina las notificaciones finalizadas
void Notify::clearFinishedNotifications()
{
for (int i = (int)notifications.size() - 1; i >= 0; --i)
{
if (notifications[i].state == ns_finished)
{
delete notifications[i].sprite;
delete notifications[i].texture;
notifications.erase(notifications.begin() + i);
}
}
}
// Muestra una notificación de texto por pantalla;
void Notify::showText(std::string text1, std::string text2, int icon)
{
// Inicializa variables
const int iconSize = 16;
const int padding = text->getCharacterSize();
const int iconSpace = icon >= 0 ? iconSize + padding : 0;
const std::string txt = text1.length() > text2.length() ? text1 : text2;
const int width = text->lenght(txt) + (padding * 2) + iconSpace;
const int height = (text->getCharacterSize() * 2) + (padding * 2);
// Posición horizontal
int despH = 0;
if (options->notifications.posH == pos_left)
{
despH = padding;
}
else if (options->notifications.posH == pos_middle)
{
despH = ((options->screen.windowWidth * options->windowSize) / 2 - (width / 2));
}
else
{
despH = (options->screen.windowWidth * options->windowSize) - width - padding;
}
// Posición vertical
int despV = 0;
if (options->notifications.posV == pos_top)
{
despV = padding;
}
else
{
despV = (options->screen.windowHeight * options->windowSize) - height - padding;
}
const int travelDist = height + padding;
// Offset
int offset = 0;
if (options->notifications.posV == pos_top)
{
offset = (int)notifications.size() > 0 ? notifications.back().y + travelDist : despV;
}
else
{
offset = (int)notifications.size() > 0 ? notifications.back().y - travelDist : despV;
}
// Crea la notificacion
notification_t n;
// Inicializa variables
n.y = offset;
n.travelDist = travelDist;
n.counter = 0;
n.state = ns_rising;
n.text1 = text1;
n.text2 = text2;
if (options->notifications.posV == pos_top)
{
n.rect = {despH, offset - travelDist, width, height};
}
else
{
n.rect = {despH, offset + travelDist, width, height};
}
// Crea la textura
n.texture = new Texture(renderer);
n.texture->createBlank(renderer, width, height, SDL_TEXTUREACCESS_TARGET);
n.texture->setBlendMode(SDL_BLENDMODE_BLEND);
// Prepara para dibujar en la textura
n.texture->setAsRenderTarget(renderer);
// Dibuja el fondo de la notificación
SDL_SetRenderDrawColor(renderer, bgColor.r, bgColor.g, bgColor.b, 255);
SDL_Rect rect;
rect = {4, 0, width - (4 * 2), height};
SDL_RenderFillRect(renderer, &rect);
rect = {4 / 2, 1, width - 4, height - 2};
SDL_RenderFillRect(renderer, &rect);
rect = {1, 4 / 2, width - 2, height - 4};
SDL_RenderFillRect(renderer, &rect);
rect = {0, 4, width, height - (4 * 2)};
SDL_RenderFillRect(renderer, &rect);
// Dibuja el icono de la notificación
if (icon >= 0)
{
Sprite *sp = new Sprite({0, 0, iconSize, iconSize}, iconTexture, renderer);
sp->setPos({padding, padding, iconSize, iconSize});
sp->setSpriteClip({iconSize * (icon % 10), iconSize * (icon / 10), iconSize, iconSize});
sp->render();
delete sp;
}
// Escribe el texto de la notificación
color_t color = {255, 255, 255};
if (text2 != "")
{ // Dos lineas de texto
text->writeColored(padding + iconSpace, padding, text1, color);
text->writeColored(padding + iconSpace, padding + text->getCharacterSize() + 1, text2, color);
}
else
{ // Una linea de texto
text->writeColored(padding + iconSpace, (height / 2) - (text->getCharacterSize() / 2), text1, color);
}
// Deja de dibujar en la textura
SDL_SetRenderTarget(renderer, nullptr);
// Crea el sprite de la notificación
n.sprite = new Sprite(n.rect, n.texture, renderer);
// Deja la notificación invisible
n.texture->setAlpha(0);
// Añade la notificación a la lista
notifications.push_back(n);
}
// Indica si hay notificaciones activas
bool Notify::active()
{
if ((int)notifications.size() > 0)
{
return true;
}
return false;
}

View File

@@ -1,87 +0,0 @@
#pragma once
#include <SDL2/SDL.h>
#include "jail_audio.h"
#include "sprite.h"
#include "text.h"
#include "texture.h"
#include "utils.h"
#include <vector>
#ifndef NOTIFY_H
#define NOTIFY_H
class Notify
{
private:
enum notification_state_e
{
ns_rising,
ns_stay,
ns_vanishing,
ns_finished
};
enum notification_position_e
{
upperLeft,
upperCenter,
upperRight,
middleLeft,
middleRight,
bottomLeft,
bottomCenter,
bottomRight
};
struct notification_t
{
std::string text1;
std::string text2;
int counter;
notification_state_e state;
notification_position_e position;
Texture *texture;
Sprite *sprite;
SDL_Rect rect;
int y;
int travelDist;
};
// Objetos y punteros
SDL_Renderer *renderer; // El renderizador de la ventana
Texture *textTexture; // Textura para la fuente de las notificaciones
Texture *iconTexture; // Textura para los iconos de las notificaciones
Text *text; // Objeto para dibujar texto
options_t *options; // Variable con todas las opciones del programa
// Variables
color_t bgColor; // Color de fondo de las notificaciones
int waitTime; // Tiempo que se ve la notificación
std::vector<notification_t> notifications; // La lista de notificaciones activas
JA_Sound_t *sound; // Sonido a reproducir cuando suena la notificación
// Elimina las notificaciones finalizadas
void clearFinishedNotifications();
public:
// Dibuja las notificaciones por pantalla
void render();
// Actualiza el estado de las notificaiones
void update();
// Constructor
Notify(SDL_Renderer *renderer, std::string iconFile, std::string bitmapFile, std::string textFile, std::string soundFile, options_t *options);
// Destructor
~Notify();
// Muestra una notificación de texto por pantalla;
void showText(std::string text1 = "", std::string text2 = "", int icon = -1);
// Indica si hay notificaciones activas
bool active();
};
#endif

View File

@@ -1,12 +1,9 @@
#pragma once
#include <SDL2/SDL.h>
#include "common/utils.h"
#include "utils.h"
#include "lang.h"
#ifndef CONST_H
#define CONST_H
// Tamaño de bloque
#define BLOCK 8
#define HALF_BLOCK BLOCK / 2
@@ -61,5 +58,3 @@ const int GAMECANVAS_THIRD_QUARTER_Y = (GAMECANVAS_HEIGHT / 4) * 3;
const color_t bgColor = {0x27, 0x27, 0x36};
const color_t noColor = {0xFF, 0xFF, 0xFF};
const color_t shdwTxtColor = {0x43, 0x43, 0x4F};
#endif

View File

@@ -1,5 +1,4 @@
#include "common/jscore.h"
#include "common/utils.h"
#include "utils.h"
#include "const.h"
#include "director.h"
#include <iostream>
@@ -60,9 +59,6 @@ Director::Director(int argc, char *argv[])
initInput();
screen = new Screen(window, renderer, asset, options);
// Inicializa los servicios online
initOnline();
}
Director::~Director()
@@ -240,9 +236,6 @@ bool Director::setFileList()
asset->add(prefix + "/data/config/demo.bin", t_data);
asset->add(prefix + "/data/config/gamecontrollerdb.txt", t_data);
// Notificaciones
asset->add(prefix + "/data/notifications/notify.png", t_bitmap);
// Musicas
asset->add(prefix + "/data/music/intro.ogg", t_music);
asset->add(prefix + "/data/music/playing.ogg", t_music);
@@ -266,7 +259,6 @@ bool Director::setFileList()
asset->add(prefix + "/data/sound/title.wav", t_sound);
asset->add(prefix + "/data/sound/clock.wav", t_sound);
asset->add(prefix + "/data/sound/powerball.wav", t_sound);
asset->add(prefix + "/data/sound/notify.wav", t_sound);
// Texturas
asset->add(prefix + "/data/gfx/balloon1.png", t_bitmap);
@@ -398,24 +390,6 @@ void Director::initOptions()
options->difficulty = DIFFICULTY_NORMAL;
options->language = ba_BA;
options->console = false;
// Opciones online
options->online.enabled = false;
options->online.server = "jaildoctor.duckdns.org";
options->online.port = 9911;
#ifdef DEBUG
options->online.gameID = "coffee_crisis_test2";
#else
options->online.gameID = "coffee_crisis";
#endif
options->online.jailerID = "";
options->online.score = 0;
// Opciones de las notificaciones
options->notifications.posV = pos_top;
options->notifications.posH = pos_left;
options->notifications.sound = true;
options->notifications.color = {48, 48, 48};
}
// Comprueba los parametros del programa
@@ -634,41 +608,6 @@ bool Director::saveConfigFile()
file << "input0=" + std::to_string(options->input[0].deviceType) + "\n";
file << "input1=" + std::to_string(options->input[1].deviceType) + "\n";
// Opciones sobre la conexión online
file << "\n## ONLINE OPTIONS\n";
file << "enabled=" + boolToString(options->online.enabled) + "\n";
file << "server=" + options->online.server + "\n";
file << "port=" + std::to_string(options->online.port) + "\n";
file << "jailerID=" + options->online.jailerID + "\n";
// Opciones de las notificaciones
file << "\n## NOTIFICATION OPTIONS\n";
file << "## notifications.posV = pos_top | pos_bottom\n";
if (options->notifications.posV == pos_top)
{
file << "notifications.posV=pos_top\n";
}
else
{
file << "notifications.posV=pos_bottom\n";
}
file << "## notifications.posH = pos_left | pos_middle | pos_right\n";
if (options->notifications.posH == pos_left)
{
file << "notifications.posH=pos_left\n";
}
else if (options->notifications.posH == pos_middle)
{
file << "notifications.posH=pos_middle\n";
}
else
{
file << "notifications.posH=pos_right\n";
}
file << "notifications.sound=" + boolToString(options->notifications.sound) + "\n";
// Cierra el fichero
file.close();
@@ -730,66 +669,6 @@ void Director::run()
}
}
// Inicializa los servicios online
void Director::initOnline()
{
if (options->online.sessionEnabled)
{ // Si ya ha iniciado la sesión, que no continue
return;
}
if (options->online.jailerID == "")
{ // Jailer ID no definido
options->online.enabled = false;
}
else
{ // Jailer ID iniciado
options->online.enabled = options->online.sessionEnabled = true;
// Establece el servidor y el puerto
jscore::init(options->online.server, options->online.port);
#ifdef DEBUG
const std::string caption = options->online.jailerID + " (DEBUG)";
#else
const std::string caption = options->online.jailerID;
#endif
// screen->showNotification(caption, lang->getText(85), 12);
screen->showNotification(caption, lang->getText(85));
if (options->console)
{
std::cout << caption << std::endl;
}
// Obtiene la información de puntuaciones online
if (!jscore::initOnlineScore(options->online.gameID))
{
screen->showNotification(lang->getText(80), options->online.server);
if (options->console)
{
std::cout << "Can't connect to " << options->online.server << std::endl;
}
options->online.enabled = false;
return;
}
// Obten la puntuación online para el jailerID
const int points = jscore::getUserPoints(options->online.gameID, options->online.jailerID);
if (points == 0)
{ // Fallo de conexión o no hay registros
screen->showNotification(lang->getText(81), lang->getText(82));
if (options->console)
{
std::cout << "Can't get online scores" << std::endl;
}
}
else
{
options->online.score = points;
}
}
}
// Asigna variables a partir de dos cadenas
bool Director::setOptions(options_t *options, std::string var, std::string value)
{
@@ -885,65 +764,6 @@ bool Director::setOptions(options_t *options, std::string var, std::string value
options->input[1].deviceType = std::stoi(value);
}
// Opciones onlince
else if (var == "enabled")
{
options->online.enabled = stringToBool(value);
}
else if (var == "server")
{
options->online.server = value;
}
else if (var == "port")
{
if (value == "")
{
value = "0";
}
options->online.port = std::stoi(value);
}
else if (var == "jailerID")
{
options->online.jailerID = toLower(value);
}
// Opciones de notificaciones
else if (var == "notifications.posH")
{
if (value == "pos_left")
{
options->notifications.posH = pos_left;
}
else if (value == "pos_middle")
{
options->notifications.posH = pos_middle;
}
else
{
options->notifications.posH = pos_right;
}
}
else if (var == "notifications.posV")
{
if (value == "pos_top")
{
options->notifications.posV = pos_top;
}
else
{
options->notifications.posV = pos_bottom;
}
}
else if (var == "notifications.sound")
{
options->notifications.sound = stringToBool(value);
}
// Lineas vacias o que empiezan por comentario
else if (var == "" || var.substr(0, 1) == "#")
{

View File

@@ -3,17 +3,17 @@
#include <SDL2/SDL.h>
#include "balloon.h"
#include "bullet.h"
#include "common/asset.h"
#include "common/input.h"
#include "common/jail_audio.h"
#include "common/menu.h"
#include "common/movingsprite.h"
#include "common/screen.h"
#include "common/smartsprite.h"
#include "common/sprite.h"
#include "common/text.h"
#include "common/utils.h"
#include "common/writer.h"
#include "asset.h"
#include "input.h"
#include "jail_audio.h"
#include "menu.h"
#include "movingsprite.h"
#include "screen.h"
#include "smartsprite.h"
#include "sprite.h"
#include "text.h"
#include "utils.h"
#include "writer.h"
#include "const.h"
#include "fade.h"
#include "game.h"
@@ -23,9 +23,6 @@
#include "player.h"
#include "title.h"
#ifndef DIRECTOR_H
#define DIRECTOR_H
// Textos
#define WINDOW_CAPTION "Coffee Crisis"
@@ -59,9 +56,6 @@ private:
// Inicializa el objeto input
void initInput();
// Inicializa los servicios online
void initOnline();
// Inicializa las opciones del programa
void initOptions();
@@ -105,5 +99,3 @@ public:
// Bucle principal
void run();
};
#endif

View File

@@ -1,348 +0,0 @@
#include "common/jail_audio.h"
#include "common/jscore.h"
#include "const.h"
#include "enter_id.h"
#include <iostream>
// Constructor
EnterID::EnterID(SDL_Renderer *renderer, Screen *screen, Asset *asset, Lang *lang, options_t *options, section_t *section)
{
// Copia la dirección de los objetos
this->renderer = renderer;
this->screen = screen;
this->asset = asset;
this->lang = lang;
this->options = options;
this->section = section;
// Reserva memoria para los punteros
eventHandler = new SDL_Event();
texture = new Texture(renderer, asset->get("smb2.png"));
text = new Text(asset->get("smb2.txt"), texture, renderer);
// Crea la textura para el texto que se escribe en pantalla
textTexture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, GAMECANVAS_WIDTH, GAMECANVAS_HEIGHT);
if (textTexture == nullptr)
{
if (options->console)
{
std::cout << "Error: textTexture could not be created!\nSDL Error: " << SDL_GetError() << std::endl;
}
}
SDL_SetTextureBlendMode(textTexture, SDL_BLENDMODE_BLEND);
// Inicializa variables
oldJailerID = options->online.jailerID;
loopRunning = true;
counter = 0;
ticks = 0;
ticksSpeed = 15;
jailerIDPos = 0;
initName();
// Escribe el texto en la textura
fillTexture();
}
// Destructor
EnterID::~EnterID()
{
delete eventHandler;
delete text;
delete texture;
}
// Bucle principal
void EnterID::run()
{
while (loopRunning)
{
update();
checkEvents();
render();
}
}
// Comprueba el manejador de eventos
void EnterID::checkEvents()
{
// Comprueba los eventos que hay en la cola
while (SDL_PollEvent(eventHandler) != 0)
{
// Evento de salida de la aplicación
if (eventHandler->type == SDL_QUIT)
{
section->name = SECTION_PROG_QUIT;
loopRunning = false;
break;
}
// Comprueba las teclas que se han pulsado
if ((eventHandler->type == SDL_KEYDOWN && eventHandler->key.repeat == 0) || (eventHandler->type == SDL_JOYBUTTONDOWN))
{
if (eventHandler->key.keysym.scancode == SDL_SCANCODE_RETURN)
{
options->online.jailerID = toLower((std::string)name);
endSection();
break;
}
if (eventHandler->key.keysym.scancode >= SDL_SCANCODE_A && eventHandler->key.keysym.scancode <= SDL_SCANCODE_Z)
{ // Si pulsa una letra
if (pos < maxLenght)
{
name[pos++] = eventHandler->key.keysym.scancode + 61;
name[pos] = 0;
}
}
else if (eventHandler->key.keysym.scancode >= SDL_SCANCODE_1 && eventHandler->key.keysym.scancode <= SDL_SCANCODE_9)
{ // Si pulsa un número
if (pos < maxLenght)
{ // En ascii el '0' va antes del '1', pero en scancode el '0' va despues de '9'
name[pos++] = eventHandler->key.keysym.scancode + 19;
name[pos] = 0;
}
}
else if (eventHandler->key.keysym.scancode == SDL_SCANCODE_0)
{
if (pos < maxLenght)
{
name[pos++] = 48;
name[pos] = 0;
}
}
else if (eventHandler->key.keysym.scancode == SDL_SCANCODE_BACKSPACE)
{
if (pos > 0)
{
name[--pos] = 0;
}
}
else if (eventHandler->key.keysym.scancode == SDL_SCANCODE_ESCAPE)
{
section->name = SECTION_PROG_QUIT;
loopRunning = false;
break;
}
else if (eventHandler->key.keysym.scancode == SDL_SCANCODE_F1)
{
screen->setWindowSize(1);
break;
}
else if (eventHandler->key.keysym.scancode == SDL_SCANCODE_F2)
{
screen->setWindowSize(2);
break;
}
else if (eventHandler->key.keysym.scancode == SDL_SCANCODE_F3)
{
screen->setWindowSize(3);
break;
}
else if (eventHandler->key.keysym.scancode == SDL_SCANCODE_F4)
{
screen->setWindowSize(4);
break;
}
}
}
}
// Actualiza las variables
void EnterID::update()
{
// Comprueba que la diferencia de ticks sea mayor a la velocidad del juego
if (SDL_GetTicks() - ticks > ticksSpeed)
{
// Actualiza el contador de ticks
ticks = SDL_GetTicks();
// Actualiza el contador
counter++;
// Actualiza el cursor
cursor = (counter % 20 >= 10) ? " " : "_";
// Actualiza las notificaciones
screen->updateNotifier();
}
}
// Dibuja en pantalla
void EnterID::render()
{
// Prepara para empezar a dibujar en la textura de juego
screen->start();
// Dibuja la textura con el texto en pantalla
SDL_RenderCopy(renderer, textTexture, nullptr, nullptr);
// Escribe el jailerID
const std::string jailerID = (std::string)name + cursor;
const color_t color = stringToColor(options->palette, "white");
text->writeDX(TXT_CENTER | TXT_COLOR, GAMECANVAS_CENTER_X, jailerIDPos, jailerID, 1, color);
// Vuelca el contenido del renderizador en pantalla
screen->blit();
}
// Inicializa los textos
void EnterID::iniTexts()
{
const color_t orangeColor = {0xFF, 0x7A, 0x00};
const color_t noColor = {0xFF, 0xFF, 0xFF};
texts.clear();
texts.push_back({lang->getText(89), orangeColor});
texts.push_back({"", noColor});
texts.push_back({lang->getText(90), noColor});
texts.push_back({lang->getText(91), noColor});
texts.push_back({lang->getText(92), noColor});
texts.push_back({"", noColor});
texts.push_back({"", noColor});
texts.push_back({"", noColor});
texts.push_back({"JAILER_ID:", orangeColor});
}
// Escribe el texto en la textura
void EnterID::fillTexture()
{
const color_t shdwTxtColor = {0x43, 0x43, 0x4F};
// Inicializa los textos
iniTexts();
// Rellena la textura con un color de fondo
SDL_SetRenderTarget(renderer, textTexture);
SDL_SetRenderDrawColor(renderer, bgColor.r, bgColor.g, bgColor.b, 0xFF);
SDL_RenderClear(renderer);
// Añade el efecto de degradado en el fondo
//Texture *gradient = new Texture(renderer, asset->get("title_gradient.png"));
//SDL_Rect rect = {0, 0, GAMECANVAS_WIDTH, GAMECANVAS_HEIGHT};
//gradient->render(renderer, 0, 0, &rect);
//delete gradient;
// Escribe el texto en la textura
const int desp = 40;
const int size = text->getCharacterSize() + 2;
int i = 0;
for (auto t : texts)
{
text->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, PLAY_AREA_CENTER_X, (i * size) + desp, t.label, 1, t.color, 1, shdwTxtColor);
i++;
}
jailerIDPos = ((i + 1) * size) + desp;
SDL_SetRenderTarget(renderer, nullptr);
}
// Inicializa los servicios online
void EnterID::initOnline()
{
// Si ya ha iniciado la sesión y no ha cambiado el jailerID, que no continue
if (options->online.sessionEnabled)
{
if (oldJailerID == options->online.jailerID)
{
return;
}
}
if (options->online.jailerID == "")
{ // Jailer ID no definido
options->online.enabled = false;
options->online.sessionEnabled = false;
}
else
{ // Jailer ID iniciado
options->online.enabled = options->online.sessionEnabled = true;
// Establece el servidor y el puerto
jscore::init(options->online.server, options->online.port);
#ifdef DEBUG
const std::string caption = options->online.jailerID + " (DEBUG)";
#else
const std::string caption = options->online.jailerID;
#endif
// screen->showNotification(caption, lang->getText(85), 12);
screen->showNotification(caption, lang->getText(85));
if (options->console)
{
std::cout << caption << std::endl;
}
// Obtiene la información de puntuaciones online
if (!jscore::initOnlineScore(options->online.gameID))
{
screen->showNotification(lang->getText(80), options->online.server);
if (options->console)
{
std::cout << "Can't connect to " << options->online.server << std::endl;
}
options->online.enabled = false;
return;
}
// Obten la puntuación online para el jailerID
const int points = jscore::getUserPoints(options->online.gameID, options->online.jailerID);
if (points == 0)
{ // Fallo de conexión o no hay registros
screen->showNotification(lang->getText(81), lang->getText(82));
if (options->console)
{
std::cout << "Can't get online scores" << std::endl;
}
}
else
{
options->online.score = points;
}
}
}
// Termina la sección
void EnterID::endSection()
{
loopRunning = false;
initOnline();
}
// Inicializa el vector utilizado para almacenar el texto que se escribe en pantalla
void EnterID::initName()
{
// Calcula el tamaño del vector
name[0] = 0;
maxLenght = sizeof(name) / sizeof(name[pos]);
// Inicializa el vector con ceros
for (int i = 0; i < maxLenght; ++i)
{
name[i] = 0;
}
// Si no hay definido ningun JailerID, coloca el cursor en primera posición
if (options->online.jailerID == "")
{
pos = 0;
}
else
{ // En caso contrario, copia el texto al vector y coloca el cursor en posición
const int len = std::min((int)options->online.jailerID.size(), maxLenght);
for (int i = 0; i < len; ++i)
{
name[i] = (char)options->online.jailerID[i];
}
pos = len;
}
}

View File

@@ -1,85 +0,0 @@
#pragma once
#include <SDL2/SDL.h>
#include "common/asset.h"
#include "common/screen.h"
#include "common/utils.h"
#include "common/text.h"
#include "common/texture.h"
#include <string>
#include <vector>
#ifndef ENTER_ID_H
#define ENTER_ID_H
class EnterID
{
private:
struct captions_t
{
std::string label; // Texto a escribir
color_t color; // Color del texto
};
// Punteros y objetos
Asset *asset; // Objeto con los ficheros de recursos
options_t *options; // Puntero a las opciones del juego
Screen *screen; // Objeto encargado de dibujar en pantalla
Lang *lang; // Objeto para gestionar los textos en diferentes idiomas
SDL_Event *eventHandler; // Manejador de eventos
SDL_Renderer *renderer; // El renderizador de la ventana
SDL_Texture *textTexture; // Textura para dibujar el texto
Text *text; // Objeto para escribir texto en pantalla
Texture *texture; // Textura para la fuente para el texto
section_t *section; // Estado del bucle principal para saber si continua o se sale
// Variables
bool loopRunning; // Indica si ha de terminar el bucle principal
int counter; // Contador
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<captions_t> texts; // Vector con los textos
std::string cursor; // Contiene el caracter que se muestra como cursor
char name[15]; // Aqui se guardan los caracteres de las teclas que se van pulsando
int pos; // Posición actual en el vector name
int maxLenght; // Tamaño máximo del jailerID
std::string oldJailerID; // Almacena el valor de jailerID al inicio para ver si se ha modificado
int jailerIDPos; // Posición en el eje Y donde ser va a escribir el texto
// Actualiza las variables
void update();
// Dibuja en pantalla
void render();
// Comprueba el manejador de eventos
void checkEvents();
// Inicializa los textos
void iniTexts();
// Escribe el texto en la textura
void fillTexture();
// Inicializa los servicios online
void initOnline();
// Termina la sección
void endSection();
// Inicializa el vector utilizado para almacenar el texto que se escribe en pantalla
void initName();
public:
// Constructor
EnterID(SDL_Renderer *renderer, Screen *screen, Asset *asset, Lang *lang, options_t *options, section_t *section);
// Destructor
~EnterID();
// Bucle principal
void run();
};
#endif

View File

@@ -1,10 +1,7 @@
#pragma once
#include <SDL2/SDL.h>
#include "common/texture.h"
#ifndef FADE_H
#define FADE_H
#include "texture.h"
// Tipos de fundido
#define FADE_FULLSCREEN 0
@@ -53,5 +50,3 @@ public:
// Establece el tipo de fade
void setFadeType(Uint8 fadeType);
};
#endif

View File

@@ -1,5 +1,4 @@
#include "game.h"
#include "common/jscore.h"
// Constructor
Game::Game(int numPlayers, int currentStage, SDL_Renderer *renderer, Screen *screen, Asset *asset, Lang *lang, Input *input, bool demo, options_t *options, section_t *section)
@@ -69,7 +68,6 @@ Game::Game(int numPlayers, int currentStage, SDL_Renderer *renderer, Screen *scr
Game::~Game()
{
saveScoreFile();
sendOnlineScore();
saveDemoFile();
// Restaura el metodo de control
@@ -773,38 +771,6 @@ bool Game::saveScoreFile()
return success;
}
// Sube la puntuación online
bool Game::sendOnlineScore()
{
if (!options->online.enabled)
{
return true;
}
if (demo.enabled)
{
return true;
}
const int score = players[0]->getScore();
if (score <= options->online.score)
{
return true;
}
if (jscore::updateUserPoints(options->online.gameID, options->online.jailerID, score))
{
options->online.score = score;
screen->showNotification(lang->getText(86) + std::to_string(score), "", 2);
return true;
}
else
{
screen->showNotification(lang->getText(86), lang->getText(87));
return false;
}
}
// Guarda el fichero de datos para la demo
bool Game::saveDemoFile()
{
@@ -1621,12 +1587,6 @@ void Game::updateHiScore()
// Actualiza la máxima puntuación
hiScore = player->getScore();
// Cambia el nombre del jugador con la máxima puntuación
if (options->online.enabled)
{
hiScoreName = options->online.jailerID.substr(0, 12) + " - ";
}
// Almacena la máxima puntuación en el fichero junto con un checksum
scoreDataFile[0] = hiScore;
scoreDataFile[1] = hiScore % 43;
@@ -2793,9 +2753,6 @@ void Game::update()
// Actualiza el contador de ticks
ticks = SDL_GetTicks();
// Actualiza las notificaciones
screen->updateNotifier();
// Actualiza el contador de juego
counter++;
@@ -3400,9 +3357,6 @@ void Game::updatePausedGame()
// Actualiza el contador de ticks
ticks = SDL_GetTicks();
// Actualiza las notificaciones
screen->updateNotifier();
if (leavingPauseMenu)
{
if (pauseCounter > 0)
@@ -3545,9 +3499,6 @@ void Game::updateGameOverScreen()
// Actualiza el contador de ticks
ticks = SDL_GetTicks();
// Actualiza las notificaciones
screen->updateNotifier();
// Actualiza la lógica del menu
gameOverMenu->update();
@@ -3693,9 +3644,6 @@ void Game::runGameOverScreen()
// Guarda los puntos
saveScoreFile();
// Sube la puntuación online
sendOnlineScore();
// Reinicia el menu
gameOverMenu->reset();
@@ -3985,23 +3933,5 @@ void Game::setHiScore()
{
// Carga el fichero de puntos
loadScoreFile();
// Establece el resto de variables
if (options->online.enabled)
{
if (jscore::getNumUsers() > 0)
{
hiScoreName = jscore::getUserName(0).substr(0, 12) + " - ";
hiScore = (Uint32)jscore::getPoints(0);
}
else
{
hiScoreName = "Bacteriol - ";
hiScore = 10;
}
}
else
{
hiScoreName = "";
}
hiScoreName = "";
}

View File

@@ -3,26 +3,23 @@
#include <SDL2/SDL.h>
#include "balloon.h"
#include "bullet.h"
#include "common/asset.h"
#include "common/input.h"
#include "common/jail_audio.h"
#include "common/menu.h"
#include "common/movingsprite.h"
#include "common/screen.h"
#include "common/smartsprite.h"
#include "common/sprite.h"
#include "common/text.h"
#include "common/utils.h"
#include "common/writer.h"
#include "asset.h"
#include "input.h"
#include "jail_audio.h"
#include "menu.h"
#include "movingsprite.h"
#include "screen.h"
#include "smartsprite.h"
#include "sprite.h"
#include "text.h"
#include "utils.h"
#include "writer.h"
#include "const.h"
#include "fade.h"
#include "item.h"
#include "player.h"
#include <iostream>
#ifndef GAME_H
#define GAME_H
// Cantidad de elementos a escribir en los ficheros de datos
#define TOTAL_SCORE_DATA 3
#define TOTAL_DEMO_DATA 2000
@@ -266,9 +263,6 @@ private:
// Guarda el fichero de puntos
bool saveScoreFile();
// Sube la puntuación online
bool sendOnlineScore();
// Guarda el fichero de datos para la demo
bool saveDemoFile();
@@ -528,5 +522,3 @@ public:
// Bucle para el juego
void run();
};
#endif

View File

@@ -1,286 +0,0 @@
#include "hiscore_table.h"
#include "common/jscore.h"
#include <iostream>
const Uint8 SELF = 0;
// Constructor
HiScoreTable::HiScoreTable(SDL_Renderer *renderer, Screen *screen, Asset *asset, Input *input, Lang *lang, options_t *options, section_t *section)
{
// Copia los punteros
this->renderer = renderer;
this->screen = screen;
this->asset = asset;
this->input = input;
this->lang = lang;
this->section = section;
this->options = options;
// Reserva memoria para los punteros
eventHandler = new SDL_Event();
text = new Text(asset->get("smb2.png"), asset->get("smb2.txt"), renderer);
// Crea un backbuffer para el renderizador
backbuffer = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, GAMECANVAS_WIDTH, GAMECANVAS_HEIGHT);
if (backbuffer == nullptr)
{
if (options->console)
{
std::cout << "Error: textTexture could not be created!\nSDL Error: " << SDL_GetError() << std::endl;
}
}
// Inicializa variables
section->name = SELF;
ticks = 0;
ticksSpeed = 15;
manualQuit = false;
counter = 0;
counterEnd = 600;
}
// Destructor
HiScoreTable::~HiScoreTable()
{
delete eventHandler;
delete text;
SDL_DestroyTexture(backbuffer);
}
// Actualiza las variables
void HiScoreTable::update()
{
// Comprueba los eventos
checkEventHandler();
// Comprueba las entradas
checkInput();
// Actualiza las variables
if (SDL_GetTicks() - ticks > ticksSpeed)
{
// Actualiza el contador de ticks
ticks = SDL_GetTicks();
// Actualiza las notificaciones
screen->updateNotifier();
if (mode == mhst_auto)
{ // Modo automático
counter++;
if (counter == counterEnd)
{
section->name = SECTION_PROG_TITLE;
section->subsection = SUBSECTION_TITLE_1;
}
}
else
{ // Modo manual
++counter %= 60000;
if (manualQuit)
{
section->name = SECTION_PROG_TITLE;
section->subsection = SUBSECTION_TITLE_3;
}
}
}
}
// Pinta en pantalla
void HiScoreTable::render()
{
// Pinta en pantalla
SDL_Rect window = {0, 0, GAMECANVAS_WIDTH, GAMECANVAS_HEIGHT};
const color_t orangeColor = {0xFF, 0x7A, 0x00};
// hay 27 letras - 7 de puntos quedan 20 caracteres 20 - nameLenght 0 numDots
const int spaceBetweenHeader = 32;
const int spaceBetweenLines = text->getCharacterSize() * 1.8f;
// Pinta en el backbuffer el texto y los sprites
SDL_SetRenderTarget(renderer, backbuffer);
SDL_SetRenderDrawColor(renderer, bgColor.r, bgColor.g, bgColor.b, 255);
SDL_RenderClear(renderer);
// Escribe el texto: Mejores puntuaciones
text->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, GAMECANVAS_CENTER_X, 8, lang->getText(42), 1, orangeColor, 1, shdwTxtColor);
// Escribe la lista de jugadores
int numUsers = jscore::getNumUsers();
for (int i = 0; i < numUsers; ++i)
{
const std::string userName = jscore::getUserName(i).substr(0, 17);
const int nameLenght = (int)userName.length();
const int numDots = 20 - nameLenght;
std::string dots = "";
for (int j = 0; j < numDots; ++j)
{
dots = dots + ".";
}
const std::string line = userName + dots + scoreToString(jscore::getPoints(i));
text->writeDX(TXT_CENTER | TXT_SHADOW, GAMECANVAS_CENTER_X, (i * spaceBetweenLines) + spaceBetweenHeader, line, 1, orangeColor, 1, shdwTxtColor);
}
// Rellena la lista con otros nombres
if (numUsers < 10)
{
std::vector<std::string> names;
names.insert(names.end(), {"Bry", "Usufondo", "G.Lucas", "P.Delgat", "P.Arrabalera", "Pelechano", "Sahuquillo", "Bacteriol", "Pepe", "Rosita"});
for (int i = numUsers; i < 10; ++i)
{
const int nameLenght = names[i - numUsers].length();
const int numDots = 20 - nameLenght;
std::string dots = "";
for (int j = 0; j < numDots; ++j)
{
dots = dots + ".";
}
const std::string line = names[i - numUsers] + dots + "0000000";
text->writeDX(TXT_CENTER | TXT_SHADOW, GAMECANVAS_CENTER_X, (i * spaceBetweenLines) + spaceBetweenHeader, line, 1, orangeColor, 1, shdwTxtColor);
}
}
if ((mode == mhst_manual) && (counter % 50 > 14))
{
text->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, GAMECANVAS_CENTER_X, GAMECANVAS_HEIGHT - 12, lang->getText(22), 1, orangeColor, 1, shdwTxtColor);
}
// Cambia el destino de renderizado
SDL_SetRenderTarget(renderer, nullptr);
// Prepara para empezar a dibujar en la textura de juego
screen->start();
// Limpia la pantalla
screen->clean(bgColor);
// Establece la ventana del backbuffer
if (mode == mhst_auto)
{
window.y = std::max(8, GAMECANVAS_HEIGHT - counter + 100);
}
else
{
window.y = 0;
}
// Copia el backbuffer al renderizador
SDL_RenderCopy(renderer, backbuffer, nullptr, &window);
// Vuelca el contenido del renderizador en pantalla
screen->blit();
}
// Comprueba los eventos
void HiScoreTable::checkEventHandler()
{
// Comprueba los eventos que hay en la cola
while (SDL_PollEvent(eventHandler) != 0)
{
// Evento de salida de la aplicación
if (eventHandler->type == SDL_QUIT)
{
section->name = SECTION_PROG_QUIT;
break;
}
}
}
// Comprueba las entradas
void HiScoreTable::checkInput()
{
if (input->checkInput(input_exit, REPEAT_FALSE))
{
section->name = SECTION_PROG_QUIT;
}
else if (input->checkInput(input_window_fullscreen, REPEAT_FALSE))
{
screen->switchVideoMode();
}
else if (input->checkInput(input_window_dec_size, REPEAT_FALSE))
{
screen->decWindowSize();
}
else if (input->checkInput(input_window_inc_size, REPEAT_FALSE))
{
screen->incWindowSize();
}
else if (input->checkInput(input_pause, REPEAT_FALSE) || input->checkInput(input_accept, REPEAT_FALSE) || input->checkInput(input_fire_left, REPEAT_FALSE) || input->checkInput(input_fire_center, REPEAT_FALSE) || input->checkInput(input_fire_right, REPEAT_FALSE))
{
if (mode == mhst_auto)
{
JA_StopMusic();
section->name = SECTION_PROG_TITLE;
section->subsection = SUBSECTION_TITLE_1;
}
else
{
if (counter > 30)
{
manualQuit = true;
}
}
}
}
// Bucle para la pantalla de instrucciones
void HiScoreTable::run(mode_hiScoreTable_e mode)
{
this->mode = mode;
while (section->name == SELF)
{
update();
render();
}
}
// Transforma un valor numérico en una cadena de 6 cifras
std::string HiScoreTable::scoreToString(Uint32 num)
{
if ((num >= 0) && (num <= 9))
{
return ("000000" + std::to_string(num));
}
if ((num >= 10) && (num <= 99))
{
return ("00000" + std::to_string(num));
}
if ((num >= 100) && (num <= 999))
{
return ("0000" + std::to_string(num));
}
if ((num >= 1000) && (num <= 9999))
{
return ("000" + std::to_string(num));
}
if ((num >= 010000) && (num <= 99999))
{
return ("00" + std::to_string(num));
}
if ((num >= 100000) && (num <= 999999))
{
return ("0" + std::to_string(num));
}
if ((num >= 1000000) && (num <= 9999999))
{
return (std::to_string(num));
}
return (std::to_string(num));
}

View File

@@ -1,71 +0,0 @@
#pragma once
#include <SDL2/SDL.h>
#include "common/asset.h"
#include "common/input.h"
#include "common/jail_audio.h"
#include "common/screen.h"
#include "common/sprite.h"
#include "common/text.h"
#include "common/utils.h"
#include "const.h"
#ifndef HISCORE_TABLE_H
#define HISCORE_TABLE_H
enum mode_hiScoreTable_e
{
mhst_manual,
mhst_auto
};
class HiScoreTable
{
private:
// Objetos y punteros
SDL_Renderer *renderer; // El renderizador de la ventana
Screen *screen; // Objeto encargado de dibujar en pantalla
SDL_Event *eventHandler; // Manejador de eventos
SDL_Texture *backbuffer; // Textura para usar como backbuffer
Asset *asset; // Objeto que gestiona todos los ficheros de recursos
Input *input; // Objeto pata gestionar la entrada
Lang *lang; // Objeto para gestionar los textos en diferentes idiomas
Text *text; // Objeto para escribir texto
options_t *options; // Opciones y parametros del programa
section_t *section; // Estado del bucle principal para saber si continua o se sale
// Variables
Uint16 counter; // Contador
Uint16 counterEnd; // Valor final para el contador
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
bool manualQuit; // Indica si se quiere salir del modo manual
mode_hiScoreTable_e mode; // Modo en el que se van a ejecutar las instrucciones
// Actualiza las variables
void update();
// Pinta en pantalla
void render();
// Comprueba los eventos
void checkEventHandler();
// Comprueba las entradas
void checkInput();
// Transforma un valor numérico en una cadena de 6 cifras
std::string scoreToString(Uint32 num);
public:
// Constructor
HiScoreTable(SDL_Renderer *renderer, Screen *screen, Asset *asset, Input *input, Lang *lang, options_t *options, section_t *section);
// Destructor
~HiScoreTable();
// Bucle principal
void run(mode_hiScoreTable_e mode);
};
#endif

View File

@@ -4,9 +4,6 @@
#include <string>
#include <vector>
#ifndef INPUT_H
#define INPUT_H
enum inputs_e
{
// Inputs obligatorios
@@ -114,5 +111,3 @@ public:
// Hablita las entradas
void enable();
};
#endif

View File

@@ -1,18 +1,15 @@
#pragma once
#include <SDL2/SDL.h>
#include "common/asset.h"
#include "common/input.h"
#include "common/jail_audio.h"
#include "common/screen.h"
#include "common/sprite.h"
#include "common/text.h"
#include "common/utils.h"
#include "asset.h"
#include "input.h"
#include "jail_audio.h"
#include "screen.h"
#include "sprite.h"
#include "text.h"
#include "utils.h"
#include "const.h"
#ifndef INSTRUCTIONS_H
#define INSTRUCTIONS_H
enum mode_e
{
m_manual,
@@ -66,5 +63,3 @@ public:
// Bucle principal
void run(mode_e mode);
};
#endif

View File

@@ -398,9 +398,6 @@ void Intro::update()
// Actualiza las escenas de la intro
updateScenes();
// Actualiza las notificaciones
screen->updateNotifier();
}
}

View File

@@ -1,13 +1,13 @@
#pragma once
#include <SDL2/SDL.h>
#include "common/asset.h"
#include "common/input.h"
#include "common/jail_audio.h"
#include "common/screen.h"
#include "common/smartsprite.h"
#include "common/utils.h"
#include "common/writer.h"
#include "asset.h"
#include "input.h"
#include "jail_audio.h"
#include "screen.h"
#include "smartsprite.h"
#include "utils.h"
#include "writer.h"
#include "const.h"
#include <vector>

View File

@@ -1,11 +1,8 @@
#pragma once
#include <SDL2/SDL.h>
#include "common/animatedsprite.h"
#include "common/utils.h"
#ifndef ITEM_H
#define ITEM_H
#include "animatedsprite.h"
#include "utils.h"
// Tipos de objetos
#define ITEM_POINTS_1_DISK 1
@@ -41,6 +38,7 @@ private:
// Actualiza la posición y estados del objeto
void move();
public:
Uint16 timeToLive; // Temporizador con el tiempo que el objeto está presente
@@ -56,7 +54,6 @@ public:
// Pinta el objeto en la pantalla
void render();
// Pone a cero todos los valores del objeto
void disable();
@@ -93,5 +90,3 @@ public:
// Informa si el objeto ha colisionado con el suelo
bool isOnFloor();
};
#endif

View File

@@ -1,12 +1,9 @@
#pragma once
#include <SDL2/SDL.h>
#include "common/asset.h"
#include "asset.h"
#include <string>
#ifndef LANG_H
#define LANG_H
// Códigos de idioma
#define es_ES 0
#define ba_BA 1
@@ -36,4 +33,3 @@ public:
// Obtiene la cadena de texto del indice
std::string getText(int index);
};
#endif

View File

@@ -119,9 +119,6 @@ void Logo::update()
// Comprueba si ha terminado el logo
checkLogoEnd();
// Actualiza las notificaciones
screen->updateNotifier();
}
}

View File

@@ -1,17 +1,14 @@
#pragma once
#include <SDL2/SDL.h>
#include "common/asset.h"
#include "common/input.h"
#include "common/jail_audio.h"
#include "common/screen.h"
#include "common/sprite.h"
#include "common/utils.h"
#include "asset.h"
#include "input.h"
#include "jail_audio.h"
#include "screen.h"
#include "sprite.h"
#include "utils.h"
#include "const.h"
#ifndef LOGO_H
#define LOGO_H
// Clase Logo
class Logo
{
@@ -59,5 +56,3 @@ public:
// Bucle principal
void run();
};
#endif

View File

@@ -1,4 +1,4 @@
#include "../const.h"
#include "const.h"
#include "menu.h"
#include <iostream>
@@ -700,7 +700,7 @@ void Menu::render()
else
{ // Si no es seleccionable
if ((item[i].linkedUp) && (i == selector.index + 1))
{// Si el elemento está enlazado con el elemento superior se pinta del color del selector
{ // Si el elemento está enlazado con el elemento superior se pinta del color del selector
const color_t color = {selector.itemColor.r, selector.itemColor.g, selector.itemColor.b};
text->writeColored(item[i].rect.x, item[i].rect.y, item[i].label, color);
}

View File

@@ -11,9 +11,6 @@
#include <sstream>
#include <vector>
#ifndef MENU_H
#define MENU_H
// Tipos de fondos para el menu
#define MENU_BACKGROUND_TRANSPARENT 0
#define MENU_BACKGROUND_SOLID 1
@@ -232,5 +229,3 @@ public:
// Establece el rectangulo de fondo del menu
void setRectSize(int w = 0, int h = 0);
};
#endif

View File

@@ -3,9 +3,6 @@
#include <SDL2/SDL.h>
#include "sprite.h"
#ifndef MOVINGSPRITE_H
#define MOVINGSPRITE_H
// Clase MovingSprite. Añade posicion y velocidad en punto flotante
class MovingSprite : public Sprite
{
@@ -163,5 +160,3 @@ public:
// Devuelve el incremento en el eje X en pixels
int getIncX();
};
#endif

View File

@@ -1,14 +1,11 @@
#pragma once
#include <SDL2/SDL.h>
#include "common/animatedsprite.h"
#include "common/asset.h"
#include "common/input.h"
#include "common/texture.h"
#include "common/utils.h"
#ifndef PLAYER_H
#define PLAYER_H
#include "animatedsprite.h"
#include "asset.h"
#include "input.h"
#include "texture.h"
#include "utils.h"
// Contadores
#define DEATH_COUNTER 350
@@ -37,7 +34,7 @@ private:
AnimatedSprite *bodySprite; // Sprite para dibujar el cuerpo
AnimatedSprite *legsSprite; // Sprite para dibujar las piernas
AnimatedSprite *deathSprite; // Sprite para dibujar el jugador derrotado
AnimatedSprite *fireSprite; // Sprite para dibujar el aura del jugador con el poder a tope
AnimatedSprite *fireSprite; // Sprite para dibujar el aura del jugador con el poder a tope
// Variables
float posX; // Posicion en el eje X
@@ -217,5 +214,3 @@ public:
// Obtiene el valor de la variable
Uint16 getDeathCounter();
};
#endif

View File

@@ -11,9 +11,6 @@ Screen::Screen(SDL_Window *window, SDL_Renderer *renderer, Asset *asset, options
this->options = options;
this->asset = asset;
// Crea los objetos
notify = new Notify(renderer, asset->get("notify.png"), asset->get("smb2.png"), asset->get("smb2.txt"), asset->get("notify.wav"), options);
gameCanvasWidth = options->gameWidth;
gameCanvasHeight = options->gameHeight;
borderWidth = options->borderWidth * 2;
@@ -47,7 +44,6 @@ Screen::Screen(SDL_Window *window, SDL_Renderer *renderer, Asset *asset, options
// Destructor
Screen::~Screen()
{
delete notify;
SDL_DestroyTexture(gameCanvas);
}
@@ -77,9 +73,6 @@ void Screen::blit()
// Copia la textura de juego en el renderizador en la posición adecuada
SDL_RenderCopy(renderer, gameCanvas, nullptr, &dest);
// Dibuja las notificaciones
renderNotifications();
// Muestra por pantalla el renderizador
SDL_RenderPresent(renderer);
}
@@ -178,9 +171,6 @@ void Screen::setVideoMode(int videoMode)
options->videoMode = videoMode;
options->screen.windowWidth = windowWidth;
options->screen.windowHeight = windowHeight;
// Establece el tamaño de las notificaciones
setNotificationSize();
}
// Camibia entre pantalla completa y ventana
@@ -384,53 +374,3 @@ void Screen::renderFX()
renderFade();
renderSpectrumFade();
}
// Actualiza el notificador
void Screen::updateNotifier()
{
notify->update();
notifyActive = notify->active();
}
// Muestra una notificación de texto por pantalla;
void Screen::showNotification(std::string text1, std::string text2, int icon)
{
notify->showText(text1, text2, icon);
}
// Dibuja las notificaciones
void Screen::renderNotifications()
{
if (!notifyActive)
{
return;
}
SDL_RenderSetLogicalSize(renderer, notificationLogicalWidth, notificationLogicalHeight);
notify->render();
SDL_RenderSetLogicalSize(renderer, windowWidth, windowHeight);
}
// Establece el tamaño de las notificaciones
void Screen::setNotificationSize()
{
if (options->videoMode == 0)
{
if (options->windowSize == 3)
{
notificationLogicalWidth = (windowWidth * 3) / 2;
notificationLogicalHeight = (windowHeight * 3) / 2;
}
else
{
notificationLogicalWidth = windowWidth * 2;
notificationLogicalHeight = windowHeight * 2;
}
}
if (options->videoMode == SDL_WINDOW_FULLSCREEN_DESKTOP)
{
notificationLogicalWidth = windowWidth / 3;
notificationLogicalHeight = windowHeight / 3;
}
}

View File

@@ -2,14 +2,10 @@
#include <SDL2/SDL.h>
#include "asset.h"
#include "notify.h"
#include "utils.h"
#include "../const.h"
#include "const.h"
#include <vector>
#ifndef SCREEN_H
#define SCREEN_H
#define FILTER_NEAREST 0
#define FILTER_LINEAL 1
@@ -22,7 +18,6 @@ private:
Asset *asset; // Objeto con el listado de recursos
SDL_Texture *gameCanvas; // Textura para completar la ventana de juego hasta la pantalla completa
options_t *options; // Variable con todas las opciones del programa
Notify *notify; // Dibuja notificaciones por pantalla
// Variables
int windowWidth; // Ancho de la pantalla o ventana
@@ -64,12 +59,6 @@ private:
// Dibuja el spectrum fade
void renderSpectrumFade();
// Dibuja las notificaciones
void renderNotifications();
// Establece el tamaño de las notificaciones
void setNotificationSize();
public:
// Constructor
Screen(SDL_Window *window, SDL_Renderer *renderer, Asset *asset, options_t *options);
@@ -134,12 +123,4 @@ public:
// Dibuja los efectos
void renderFX();
// Actualiza el notificador
void updateNotifier();
// Muestra una notificación de texto por pantalla;
void showNotification(std::string text1 = "", std::string text2 = "", int icon = -1);
};
#endif

View File

@@ -5,9 +5,6 @@
#include "utils.h"
#include <vector>
#ifndef SMARTSPRITE_H
#define SMARTSPRITE_H
// Clase SmartSprite
class SmartSprite : public AnimatedSprite
{
@@ -69,5 +66,3 @@ public:
// Obtiene el valor de la variable
bool hasFinished();
};
#endif

View File

@@ -3,9 +3,6 @@
#include <SDL2/SDL.h>
#include "texture.h"
#ifndef SPRITE_H
#define SPRITE_H
// Clase sprite
class Sprite
{
@@ -92,5 +89,3 @@ public:
// Establece los valores de posición y tamaño del sprite
void setRect(SDL_Rect rect);
};
#endif

View File

@@ -3,9 +3,6 @@
#include "sprite.h"
#include "utils.h"
#ifndef TEXT_H
#define TEXT_H
#define TXT_COLOR 1
#define TXT_SHADOW 2
#define TXT_CENTER 4
@@ -78,5 +75,3 @@ public:
// Establece si se usa un tamaño fijo de letra
void setFixedWidth(bool value);
};
#endif

View File

@@ -4,9 +4,6 @@
#include <stdio.h>
#include <string>
#ifndef TEXTURE_H
#define TEXTURE_H
class Texture
{
private:
@@ -62,5 +59,3 @@ public:
// Obtiene la textura
SDL_Texture *getSDLTexture();
};
#endif

View File

@@ -1,5 +1,4 @@
#include "title.h"
#include "common/jscore.h"
// Constructor
Title::Title(SDL_Renderer *renderer, Screen *screen, Input *input, Asset *asset, options_t *options, Lang *lang, section_t *section)
@@ -206,9 +205,6 @@ void Title::init()
// Actualiza los textos de los menus
updateMenuLabels();
// Comprueba si se puede acceder a la tabla de puntuaciones y habilita la opción de menu
setHiScoreTableOptionMenu();
}
// Actualiza las variables del objeto
@@ -223,9 +219,6 @@ void Title::update()
// Actualiza el contador de ticks
ticks = SDL_GetTicks();
// Actualiza las notificaciones
screen->updateNotifier();
switch (section->subsection)
{
// Sección 1 - Titulo desplazandose
@@ -321,10 +314,6 @@ void Title::update()
{
runInstructions(m_auto);
}
if (section->name != SECTION_PROG_QUIT)
{
runHiScoreTable(mhst_auto);
}
}
else
section->name = SECTION_PROG_LOGO;
@@ -478,23 +467,13 @@ void Title::update()
runInstructions(m_manual);
break;
case 12: // HISCORE TABLE
runHiScoreTable(mhst_manual);
break;
case 13: // JAILERID:
runEnterID();
setHiScoreTableOptionMenu();
updateMenuLabels();
break;
case 14: // ACCEPT
case 12: // ACCEPT
applyOptions();
menu.active->reset();
menu.active = menu.title;
break;
case 15: // CANCEL
case 13: // CANCEL
options = &optionsPrevious;
updateMenuLabels();
menu.active->reset();
@@ -515,10 +494,6 @@ void Title::update()
{
if (demo)
{
if (section->name != SECTION_PROG_QUIT)
{
runHiScoreTable(mhst_auto);
}
runDemoGame();
if (section->name != SECTION_PROG_QUIT)
{
@@ -918,15 +893,6 @@ void Title::updateMenuLabels()
// HOW TO PLAY
menu.options->setItemCaption(i, lang->getText(2));
i++;
// HISCORE TABLE
menu.options->setItemCaption(i, lang->getText(93));
i++;
// JAILERID;
const std::string jailerID = options->online.jailerID == "" ? lang->getText(64) : options->online.jailerID;
menu.options->setItemCaption(i, "JAILERID: " + jailerID);
i++;
// ACCEPT
menu.options->setItemCaption(i, lang->getText(9)); // ACCEPT
@@ -1004,22 +970,6 @@ void Title::runInstructions(mode_e mode)
delete instructions;
}
// Ejecuta la parte donde se muestra la tabla de puntuaciones
void Title::runHiScoreTable(mode_hiScoreTable_e mode)
{
if (!options->online.enabled)
{
section->name = SECTION_PROG_TITLE;
section->subsection = SUBSECTION_TITLE_1;
return;
}
hiScoreTable = new HiScoreTable(renderer, screen, asset, input, lang, options, section);
hiScoreTable->run(mode);
delete hiScoreTable;
}
// Ejecuta el juego en modo demo
void Title::runDemoGame()
{
@@ -1028,14 +978,6 @@ void Title::runDemoGame()
delete demoGame;
}
// Introduce el JailerID
void Title::runEnterID()
{
enterID = new EnterID(renderer, screen, asset, lang, options, section);
enterID->run();
delete enterID;
}
// Modifica las opciones para los controles de los jugadores
bool Title::updatePlayerInputs(int numPlayer)
{
@@ -1187,18 +1129,3 @@ void Title::reLoadTextures()
gradientTexture->reLoad();
createTiledBackground();
}
// Comprueba si se puede acceder a la tabla de puntuaciones y habilita la opción de menu
void Title::setHiScoreTableOptionMenu()
{
if (options->online.sessionEnabled)
{
menu.options->setSelectable(12, true);
menu.options->setGreyed(12, false);
}
else
{
menu.options->setSelectable(12, false);
menu.options->setGreyed(12, true);
}
}

View File

@@ -1,27 +1,22 @@
#pragma once
#include <SDL2/SDL.h>
#include "common/asset.h"
#include "common/input.h"
#include "common/jail_audio.h"
#include "common/menu.h"
#include "common/movingsprite.h"
#include "common/screen.h"
#include "common/smartsprite.h"
#include "common/sprite.h"
#include "common/text.h"
#include "common/utils.h"
#include "asset.h"
#include "input.h"
#include "jail_audio.h"
#include "menu.h"
#include "movingsprite.h"
#include "screen.h"
#include "smartsprite.h"
#include "sprite.h"
#include "text.h"
#include "utils.h"
#include "const.h"
#include "fade.h"
#include "game.h"
#include "enter_id.h"
#include "hiscore_table.h"
#include "instructions.h"
#include "item.h"
#ifndef TITLE_H
#define TITLE_H
// Textos
#define TEXT_COPYRIGHT "@2020,2023 JailDesigner (v2.3.1)"
@@ -50,9 +45,7 @@ private:
Input *input; // Objeto para leer las entradas de teclado o mando
Lang *lang; // Objeto para gestionar los textos en diferentes idiomas
Instructions *instructions; // Objeto para la sección de las instrucciones
HiScoreTable *hiScoreTable; // Objeto para mostrar las mejores puntuaciones online
Game *demoGame; // Objeto para lanzar la demo del juego
EnterID *enterID; // Objeto para introducir o modificar el JailerID
SDL_Event *eventHandler; // Manejador de eventos
section_t *section; // Indicador para el bucle del titulo
@@ -125,15 +118,9 @@ private:
// Ejecuta la parte donde se muestran las instrucciones
void runInstructions(mode_e mode);
// Ejecuta la parte donde se muestra la tabla de puntuaciones
void runHiScoreTable(mode_hiScoreTable_e mode);
// Ejecuta el juego en modo demo
void runDemoGame();
// Introduce el JailerID
void runEnterID();
// Modifica las opciones para los controles de los jugadores
bool updatePlayerInputs(int numPlayer);
@@ -146,9 +133,6 @@ private:
// Recarga las texturas
void reLoadTextures();
// Comprueba si se puede acceder a la tabla de puntuaciones y habilita la opción de menu
void setHiScoreTableOptionMenu();
public:
// Constructor
Title(SDL_Renderer *renderer, Screen *screen, Input *input, Asset *asset, options_t *options, Lang *lang, section_t *section);
@@ -159,5 +143,3 @@ public:
// Bucle para el titulo del juego
void run();
};
#endif

View File

@@ -5,9 +5,6 @@
#include <string>
#include <vector>
#ifndef UTILS_H
#define UTILS_H
// Dificultad del juego
#define DIFFICULTY_EASY 0
#define DIFFICULTY_NORMAL 1
@@ -100,18 +97,6 @@ struct input_t
Uint8 deviceType; // Tipo de dispositivo (teclado o mando)
};
// Estructura para el servicio online
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
std::string jailerID; // Identificador del jugador para los servicios online
int score; // Puntuación almacenada online
};
// Estructura con opciones de la pantalla
struct op_screen_t
{
@@ -119,15 +104,6 @@ struct op_screen_t
int windowHeight; // Alto de la ventana
};
// Estructura para las opciones de las notificaciones
struct op_notification_t
{
not_pos_e posH; // Ubicación de las notificaciones en pantalla
not_pos_e posV; // Ubicación de las notificaciones en pantalla
bool sound; // Indica si las notificaciones suenan
color_t color; // Color de las notificaciones
};
// Estructura con todas las opciones de configuración del programa
struct options_t
{
@@ -150,9 +126,7 @@ struct options_t
palette_e palette; // Paleta de colores a usar en el juego
bool console; // Indica si ha de mostrar información por la consola de texto
online_t online; // Datos del servicio online
op_screen_t screen; // Opciones relativas a la clase screen
op_notification_t notifications; // Opciones relativas a las notificaciones;
};
// Calcula el cuadrado de la distancia entre dos puntos
@@ -202,5 +176,3 @@ std::string boolToString(bool value);
// Convierte una cadena a minusculas
std::string toLower(std::string str);
#endif

View File

@@ -4,9 +4,6 @@
#include "sprite.h"
#include "text.h"
#ifndef WRITER_H
#define WRITER_H
// Clase Writer. Pinta texto en pantalla letra a letra a partir de una cadena y un bitmap
class Writer
{
@@ -71,5 +68,3 @@ public:
// Obtiene el valor de la variable
bool hasFinished();
};
#endif