forked from jaildesigner-jailgames/jaildoctors_dilemma
Borradas clases que no se utilizaban
This commit is contained in:
@@ -21,16 +21,12 @@ Director::Director(std::string path)
|
|||||||
if (!mAsset->check())
|
if (!mAsset->check())
|
||||||
section = SECTION_PROG_QUIT;
|
section = SECTION_PROG_QUIT;
|
||||||
|
|
||||||
// Inicializa el objeto de idioma
|
|
||||||
mLang = new Lang(mAsset);
|
|
||||||
|
|
||||||
// Crea el puntero a la estructura y carga el fichero de configuración
|
// Crea el puntero a la estructura y carga el fichero de configuración
|
||||||
mOptions = new options_t;
|
mOptions = new options_t;
|
||||||
if (!loadConfigFile())
|
if (!loadConfigFile())
|
||||||
{
|
{
|
||||||
mOptions->fullScreenMode = 0;
|
mOptions->fullScreenMode = 0;
|
||||||
mOptions->windowSize = 3;
|
mOptions->windowSize = 3;
|
||||||
mOptions->language = en_UK;
|
|
||||||
mOptions->difficulty = DIFFICULTY_NORMAL;
|
mOptions->difficulty = DIFFICULTY_NORMAL;
|
||||||
mOptions->input[0].deviceType = INPUT_USE_KEYBOARD;
|
mOptions->input[0].deviceType = INPUT_USE_KEYBOARD;
|
||||||
mOptions->input[1].deviceType = INPUT_USE_GAMECONTROLLER;
|
mOptions->input[1].deviceType = INPUT_USE_GAMECONTROLLER;
|
||||||
@@ -50,7 +46,6 @@ Director::Director(std::string path)
|
|||||||
// Aplica las opciones
|
// Aplica las opciones
|
||||||
SDL_SetWindowFullscreen(mWindow, mOptions->fullScreenMode);
|
SDL_SetWindowFullscreen(mWindow, mOptions->fullScreenMode);
|
||||||
SDL_SetWindowSize(mWindow, SCREEN_WIDTH * mOptions->windowSize, SCREEN_HEIGHT * mOptions->windowSize);
|
SDL_SetWindowSize(mWindow, SCREEN_WIDTH * mOptions->windowSize, SCREEN_HEIGHT * mOptions->windowSize);
|
||||||
mLang->setLang(mOptions->language);
|
|
||||||
|
|
||||||
// Inicializa el resto de variables
|
// Inicializa el resto de variables
|
||||||
init(section);
|
init(section);
|
||||||
@@ -63,9 +58,6 @@ Director::~Director()
|
|||||||
delete mInput;
|
delete mInput;
|
||||||
mInput = nullptr;
|
mInput = nullptr;
|
||||||
|
|
||||||
delete mLang;
|
|
||||||
mLang = nullptr;
|
|
||||||
|
|
||||||
delete mOptions;
|
delete mOptions;
|
||||||
mOptions = nullptr;
|
mOptions = nullptr;
|
||||||
|
|
||||||
@@ -87,9 +79,6 @@ void Director::init(Uint8 name)
|
|||||||
mSection.name = name;
|
mSection.name = name;
|
||||||
mSection.subsection = 0;
|
mSection.subsection = 0;
|
||||||
|
|
||||||
// Textos
|
|
||||||
mLang->setLang(mOptions->language);
|
|
||||||
|
|
||||||
// Controles
|
// Controles
|
||||||
mInput->bindKey(INPUT_UP, SDL_SCANCODE_UP);
|
mInput->bindKey(INPUT_UP, SDL_SCANCODE_UP);
|
||||||
mInput->bindKey(INPUT_DOWN, SDL_SCANCODE_DOWN);
|
mInput->bindKey(INPUT_DOWN, SDL_SCANCODE_DOWN);
|
||||||
@@ -221,7 +210,6 @@ bool Director::loadConfigFile()
|
|||||||
// Pone unos valores por defecto
|
// Pone unos valores por defecto
|
||||||
mOptions->fullScreenMode = 0;
|
mOptions->fullScreenMode = 0;
|
||||||
mOptions->windowSize = 3;
|
mOptions->windowSize = 3;
|
||||||
mOptions->language = en_UK;
|
|
||||||
mOptions->difficulty = DIFFICULTY_NORMAL;
|
mOptions->difficulty = DIFFICULTY_NORMAL;
|
||||||
mOptions->input[0].deviceType = INPUT_USE_KEYBOARD;
|
mOptions->input[0].deviceType = INPUT_USE_KEYBOARD;
|
||||||
mOptions->input[1].deviceType = INPUT_USE_GAMECONTROLLER;
|
mOptions->input[1].deviceType = INPUT_USE_GAMECONTROLLER;
|
||||||
@@ -286,8 +274,6 @@ bool Director::loadConfigFile()
|
|||||||
mOptions->fullScreenMode = 0;
|
mOptions->fullScreenMode = 0;
|
||||||
if ((mOptions->windowSize < 1) || (mOptions->windowSize > 4))
|
if ((mOptions->windowSize < 1) || (mOptions->windowSize > 4))
|
||||||
mOptions->windowSize = 3;
|
mOptions->windowSize = 3;
|
||||||
if ((mOptions->language < 0) || (mOptions->language > MAX_LANGUAGES))
|
|
||||||
mOptions->language = en_UK;
|
|
||||||
|
|
||||||
// Cierra el fichero
|
// Cierra el fichero
|
||||||
SDL_RWclose(file);
|
SDL_RWclose(file);
|
||||||
@@ -365,7 +351,7 @@ void Director::runTitle()
|
|||||||
|
|
||||||
void Director::runGame()
|
void Director::runGame()
|
||||||
{
|
{
|
||||||
mGame = new Game(mWindow, mRenderer, mAsset, mLang, mInput);
|
mGame = new Game(mWindow, mRenderer, mAsset, mInput);
|
||||||
setSection(mGame->run());
|
setSection(mGame->run());
|
||||||
delete mGame;
|
delete mGame;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,16 +3,13 @@
|
|||||||
#include "sprite.h"
|
#include "sprite.h"
|
||||||
#include "movingsprite.h"
|
#include "movingsprite.h"
|
||||||
#include "text.h"
|
#include "text.h"
|
||||||
#include "writer.h"
|
|
||||||
#include "menu.h"
|
#include "menu.h"
|
||||||
#include "const.h"
|
#include "const.h"
|
||||||
#include "jail_audio.h"
|
#include "jail_audio.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "input.h"
|
#include "input.h"
|
||||||
#include "fade.h"
|
|
||||||
#include "game.h"
|
#include "game.h"
|
||||||
#include "asset.h"
|
#include "asset.h"
|
||||||
#include "lang.h"
|
|
||||||
|
|
||||||
#ifndef DIRECTOR_H
|
#ifndef DIRECTOR_H
|
||||||
#define DIRECTOR_H
|
#define DIRECTOR_H
|
||||||
@@ -27,7 +24,6 @@ private:
|
|||||||
SDL_Renderer *mRenderer; // El renderizador de la ventana
|
SDL_Renderer *mRenderer; // El renderizador de la ventana
|
||||||
|
|
||||||
Input *mInput; // Objeto Input para gestionar las entradas
|
Input *mInput; // Objeto Input para gestionar las entradas
|
||||||
Lang *mLang; // Objeto para gestionar los textos en diferentes idiomas
|
|
||||||
Game *mGame; // Objeto para la sección del juego
|
Game *mGame; // Objeto para la sección del juego
|
||||||
Asset *mAsset; // Objeto que gestiona todos los ficheros de recursos
|
Asset *mAsset; // Objeto que gestiona todos los ficheros de recursos
|
||||||
|
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ Enemy::~Enemy()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Pinta el enemigo en pantalla
|
// Pinta el enemigo en pantalla
|
||||||
void Enemy::draw()
|
void Enemy::render()
|
||||||
{
|
{
|
||||||
sprite->getTexture()->setColor(color.r, color.g, color.b);
|
sprite->getTexture()->setColor(color.r, color.g, color.b);
|
||||||
sprite->render();
|
sprite->render();
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ public:
|
|||||||
~Enemy();
|
~Enemy();
|
||||||
|
|
||||||
// Pinta el enemigo en pantalla
|
// Pinta el enemigo en pantalla
|
||||||
void draw();
|
void render();
|
||||||
|
|
||||||
// Actualiza las variables del objeto
|
// Actualiza las variables del objeto
|
||||||
void update();
|
void update();
|
||||||
|
|||||||
169
source/fade.cpp
169
source/fade.cpp
@@ -1,169 +0,0 @@
|
|||||||
#include "fade.h"
|
|
||||||
#include "const.h"
|
|
||||||
|
|
||||||
// Constructor
|
|
||||||
Fade::Fade(SDL_Renderer *renderer)
|
|
||||||
{
|
|
||||||
mRenderer = renderer;
|
|
||||||
|
|
||||||
mBackbuffer = SDL_CreateTexture(mRenderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, SCREEN_WIDTH, SCREEN_HEIGHT);
|
|
||||||
if (mBackbuffer == NULL)
|
|
||||||
printf("Backbuffer could not be created!\nSDL Error: %s\n", SDL_GetError());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Destructor
|
|
||||||
Fade::~Fade()
|
|
||||||
{
|
|
||||||
SDL_DestroyTexture(mBackbuffer);
|
|
||||||
mBackbuffer = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Inicializa las variables
|
|
||||||
void Fade::init(Uint8 r, Uint8 g, Uint8 b)
|
|
||||||
{
|
|
||||||
mFadeType = FADE_CENTER;
|
|
||||||
mEnabled = false;
|
|
||||||
mFinished = false;
|
|
||||||
mCounter = 0;
|
|
||||||
mR = r;
|
|
||||||
mG = g;
|
|
||||||
mB = b;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Pinta una transición en pantalla
|
|
||||||
void Fade::render()
|
|
||||||
{
|
|
||||||
if (mEnabled && !mFinished)
|
|
||||||
{
|
|
||||||
switch (mFadeType)
|
|
||||||
{
|
|
||||||
case FADE_FULLSCREEN:
|
|
||||||
mRect1 = {0, 0, SCREEN_WIDTH, SCREEN_HEIGHT};
|
|
||||||
|
|
||||||
for (int i = 0; i < 256; i += 4)
|
|
||||||
{
|
|
||||||
// Dibujamos sobre el renderizador
|
|
||||||
SDL_SetRenderTarget(mRenderer, NULL);
|
|
||||||
|
|
||||||
// Copia el backbuffer con la imagen que había al renderizador
|
|
||||||
SDL_RenderCopy(mRenderer, mBackbuffer, NULL, NULL);
|
|
||||||
|
|
||||||
SDL_SetRenderDrawColor(mRenderer, mR, mG, mB, i);
|
|
||||||
SDL_RenderFillRect(mRenderer, &mRect1);
|
|
||||||
|
|
||||||
// Vuelca el renderizador en pantalla
|
|
||||||
SDL_RenderPresent(mRenderer);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Deja todos los buffers del mismo color
|
|
||||||
SDL_SetRenderTarget(mRenderer, mBackbuffer);
|
|
||||||
SDL_SetRenderDrawColor(mRenderer, mR, mG, mB, 255);
|
|
||||||
SDL_RenderClear(mRenderer);
|
|
||||||
|
|
||||||
SDL_SetRenderTarget(mRenderer, NULL);
|
|
||||||
SDL_SetRenderDrawColor(mRenderer, mR, mG, mB, 255);
|
|
||||||
SDL_RenderClear(mRenderer);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case FADE_CENTER:
|
|
||||||
mRect1 = {0, 0, SCREEN_WIDTH, 0};
|
|
||||||
mRect2 = {0, 0, SCREEN_WIDTH, 0};
|
|
||||||
|
|
||||||
SDL_SetRenderDrawColor(mRenderer, mR, mG, mB, 64);
|
|
||||||
|
|
||||||
for (int i = 0; i < mCounter; i++)
|
|
||||||
{
|
|
||||||
mRect1.h = mRect2.h = i * 4;
|
|
||||||
mRect2.y = SCREEN_HEIGHT - (i * 4);
|
|
||||||
|
|
||||||
SDL_RenderFillRect(mRenderer, &mRect1);
|
|
||||||
SDL_RenderFillRect(mRenderer, &mRect2);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((mCounter * 4) > SCREEN_HEIGHT)
|
|
||||||
mFinished = true;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case FADE_RANDOM_SQUARE:
|
|
||||||
mRect1 = {0, 0, 32, 32};
|
|
||||||
|
|
||||||
for (Uint16 i = 0; i < 50; i++)
|
|
||||||
{
|
|
||||||
// Crea un color al azar
|
|
||||||
mR = 255 * (rand() % 2);
|
|
||||||
mG = 255 * (rand() % 2);
|
|
||||||
mB = 255 * (rand() % 2);
|
|
||||||
SDL_SetRenderDrawColor(mRenderer, mR, mG, mB, 64);
|
|
||||||
|
|
||||||
// Dibujamos sobre el backbuffer
|
|
||||||
SDL_SetRenderTarget(mRenderer, mBackbuffer);
|
|
||||||
|
|
||||||
mRect1.x = rand() % (SCREEN_WIDTH - mRect1.w);
|
|
||||||
mRect1.y = rand() % (SCREEN_HEIGHT - mRect1.h);
|
|
||||||
SDL_RenderFillRect(mRenderer, &mRect1);
|
|
||||||
|
|
||||||
// Volvemos a usar el renderizador de forma normal
|
|
||||||
SDL_SetRenderTarget(mRenderer, NULL);
|
|
||||||
|
|
||||||
// Copiamos el backbuffer al renderizador
|
|
||||||
SDL_RenderCopy(mRenderer, mBackbuffer, NULL, NULL);
|
|
||||||
|
|
||||||
// Volcamos el renderizador en pantalla
|
|
||||||
SDL_RenderPresent(mRenderer);
|
|
||||||
SDL_Delay(100);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mFinished)
|
|
||||||
{
|
|
||||||
SDL_SetRenderDrawColor(mRenderer, mR, mG, mB, 255);
|
|
||||||
SDL_RenderClear(mRenderer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Actualiza las variables internas
|
|
||||||
void Fade::update()
|
|
||||||
{
|
|
||||||
if (mEnabled)
|
|
||||||
mCounter++;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Activa el fade
|
|
||||||
void Fade::activateFade()
|
|
||||||
{
|
|
||||||
mEnabled = true;
|
|
||||||
mFinished = false;
|
|
||||||
mCounter = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Comprueba si está activo
|
|
||||||
bool Fade::isEnabled()
|
|
||||||
{
|
|
||||||
return mEnabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Comprueba si ha terminado la transicion
|
|
||||||
bool Fade::hasEnded()
|
|
||||||
{
|
|
||||||
if (mFinished)
|
|
||||||
{
|
|
||||||
//mEnabled = false;
|
|
||||||
//mFinished = false;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Establece el tipo de fade
|
|
||||||
void Fade::setFadeType(Uint8 fadeType)
|
|
||||||
{
|
|
||||||
mFadeType = fadeType;
|
|
||||||
}
|
|
||||||
@@ -1,55 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include "ifdefs.h"
|
|
||||||
#include "ltexture.h"
|
|
||||||
|
|
||||||
#ifndef FADE_H
|
|
||||||
#define FADE_H
|
|
||||||
|
|
||||||
#define FADE_FULLSCREEN 0
|
|
||||||
#define FADE_CENTER 1
|
|
||||||
#define FADE_RANDOM_SQUARE 2
|
|
||||||
|
|
||||||
// Fade
|
|
||||||
class Fade
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
SDL_Renderer *mRenderer; // El renderizador de la ventana
|
|
||||||
SDL_Texture *mBackbuffer; // Textura para usar como backbuffer
|
|
||||||
Uint8 mFadeType; // Tipo de fade a realizar
|
|
||||||
Uint16 mCounter; // Contador interno
|
|
||||||
bool mEnabled; // Indica si el fade está activo
|
|
||||||
bool mFinished; // Indica si ha terminado la transición
|
|
||||||
Uint8 mR, mG, mB; // Colores para el fade
|
|
||||||
SDL_Rect mRect1; // Rectangulo usado para crear los efectos de transición
|
|
||||||
SDL_Rect mRect2; // Rectangulo usado para crear los efectos de transición
|
|
||||||
|
|
||||||
public:
|
|
||||||
// Constructor
|
|
||||||
Fade(SDL_Renderer *renderer);
|
|
||||||
|
|
||||||
// Destructor
|
|
||||||
~Fade();
|
|
||||||
|
|
||||||
// Inicializa las variables
|
|
||||||
void init(Uint8 r, Uint8 g, Uint8 b);
|
|
||||||
|
|
||||||
// Pinta una transición en pantalla
|
|
||||||
void render();
|
|
||||||
|
|
||||||
// Actualiza las variables internas
|
|
||||||
void update();
|
|
||||||
|
|
||||||
// Activa el fade
|
|
||||||
void activateFade();
|
|
||||||
|
|
||||||
// Comprueba si ha terminado la transicion
|
|
||||||
bool hasEnded();
|
|
||||||
|
|
||||||
// Comprueba si está activo
|
|
||||||
bool isEnabled();
|
|
||||||
|
|
||||||
// Establece el tipo de fade
|
|
||||||
void setFadeType(Uint8 fadeType);
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
#include "game.h"
|
#include "game.h"
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Game::Game(SDL_Window *window, SDL_Renderer *renderer, Asset *asset, Lang *lang, Input *input)
|
Game::Game(SDL_Window *window, SDL_Renderer *renderer, Asset *asset, Input *input)
|
||||||
{
|
{
|
||||||
// Inicia variables
|
// Inicia variables
|
||||||
currentRoom = "01.room";
|
currentRoom = "01.room";
|
||||||
@@ -65,7 +65,7 @@ section_t Game::run()
|
|||||||
if (section.subsection == SECTION_GAME_PLAY)
|
if (section.subsection == SECTION_GAME_PLAY)
|
||||||
{
|
{
|
||||||
update();
|
update();
|
||||||
draw();
|
render();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,16 +104,16 @@ void Game::update()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Pinta los objetos en pantalla
|
// Pinta los objetos en pantalla
|
||||||
void Game::draw()
|
void Game::render()
|
||||||
{
|
{
|
||||||
// Prepara para dibujar el frame
|
// Prepara para dibujar el frame
|
||||||
screen->start();
|
screen->start();
|
||||||
screen->clean(room->getBGColor());
|
screen->clean(room->getBGColor());
|
||||||
|
|
||||||
room->drawMap();
|
room->renderMap();
|
||||||
room->drawEnemies();
|
room->renderEnemies();
|
||||||
room->drawItems();
|
room->renderItems();
|
||||||
player->draw();
|
player->render();
|
||||||
|
|
||||||
// Texto en el centro de la pantalla
|
// Texto en el centro de la pantalla
|
||||||
SDL_Rect rect = {0, 16 * 8, PLAY_AREA_RIGHT, 8};
|
SDL_Rect rect = {0, 16 * 8, PLAY_AREA_RIGHT, 8};
|
||||||
|
|||||||
@@ -5,11 +5,8 @@
|
|||||||
#include "sprite.h"
|
#include "sprite.h"
|
||||||
#include "movingsprite.h"
|
#include "movingsprite.h"
|
||||||
#include "text.h"
|
#include "text.h"
|
||||||
#include "writer.h"
|
|
||||||
#include "menu.h"
|
#include "menu.h"
|
||||||
#include "input.h"
|
#include "input.h"
|
||||||
#include "fade.h"
|
|
||||||
#include "lang.h"
|
|
||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
#include "asset.h"
|
#include "asset.h"
|
||||||
#include "room.h"
|
#include "room.h"
|
||||||
@@ -44,7 +41,7 @@ private:
|
|||||||
void update();
|
void update();
|
||||||
|
|
||||||
// Pinta los objetos en pantalla
|
// Pinta los objetos en pantalla
|
||||||
void draw();
|
void render();
|
||||||
|
|
||||||
// Comprueba la entrada y actua
|
// Comprueba la entrada y actua
|
||||||
void checkInput();
|
void checkInput();
|
||||||
@@ -72,7 +69,7 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
Game(SDL_Window *window, SDL_Renderer *renderer, Asset *asset, Lang *lang, Input *input);
|
Game(SDL_Window *window, SDL_Renderer *renderer, Asset *asset, Input *input);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~Game();
|
~Game();
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ Item::~Item()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Pinta el objeto en pantalla
|
// Pinta el objeto en pantalla
|
||||||
void Item::draw()
|
void Item::render()
|
||||||
{
|
{
|
||||||
const int index = (counter / 2) % color.size();
|
const int index = (counter / 2) % color.size();
|
||||||
sprite->getTexture()->setColor(color[index].r, color[index].g, color[index].b);
|
sprite->getTexture()->setColor(color[index].r, color[index].g, color[index].b);
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ public:
|
|||||||
~Item();
|
~Item();
|
||||||
|
|
||||||
// Pinta el objeto en pantalla
|
// Pinta el objeto en pantalla
|
||||||
void draw();
|
void render();
|
||||||
|
|
||||||
// Actualiza las variables del objeto
|
// Actualiza las variables del objeto
|
||||||
void update();
|
void update();
|
||||||
|
|||||||
@@ -1,74 +0,0 @@
|
|||||||
#include "lang.h"
|
|
||||||
#include <iostream>
|
|
||||||
#include <fstream>
|
|
||||||
|
|
||||||
// Constructor
|
|
||||||
Lang::Lang(Asset *asset)
|
|
||||||
{
|
|
||||||
mAsset = asset;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Destructor
|
|
||||||
Lang::~Lang()
|
|
||||||
{
|
|
||||||
mAsset = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Inicializa los textos del juego en el idioma seleccionado
|
|
||||||
bool Lang::setLang(Uint8 lang)
|
|
||||||
{
|
|
||||||
std::string file;
|
|
||||||
|
|
||||||
switch (lang)
|
|
||||||
{
|
|
||||||
case es_ES:
|
|
||||||
file = mAsset->get("es_ES.txt");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case en_UK:
|
|
||||||
file = mAsset->get("en_UK.txt");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ba_BA:
|
|
||||||
file = mAsset->get("ba_BA.txt");
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
file = mAsset->get("en_UK.txt");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < MAX_TEXT_STRINGS; i++)
|
|
||||||
mTextStrings[i] = "";
|
|
||||||
|
|
||||||
bool success = false;
|
|
||||||
|
|
||||||
std::ifstream rfile(file);
|
|
||||||
if (rfile.is_open() && rfile.good())
|
|
||||||
{
|
|
||||||
success = true;
|
|
||||||
std::string buffer;
|
|
||||||
|
|
||||||
// lee el resto de datos del fichero
|
|
||||||
int index = 0;
|
|
||||||
int line_read = 0;
|
|
||||||
while (std::getline(rfile, buffer))
|
|
||||||
{
|
|
||||||
// Almacena solo las lineas impares
|
|
||||||
if (line_read % 2 == 1)
|
|
||||||
mTextStrings[index++] = buffer;
|
|
||||||
|
|
||||||
// Limpia el buffer
|
|
||||||
buffer.clear();
|
|
||||||
line_read++;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
return success;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Obtiene la cadena de texto del indice
|
|
||||||
std::string Lang::getText(int index)
|
|
||||||
{
|
|
||||||
return mTextStrings[index];
|
|
||||||
}
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include "ifdefs.h"
|
|
||||||
#include "asset.h"
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
#ifndef LANG_H
|
|
||||||
#define LANG_H
|
|
||||||
|
|
||||||
// Lang codes
|
|
||||||
#define es_ES 0
|
|
||||||
#define ba_BA 1
|
|
||||||
#define en_UK 2
|
|
||||||
#define MAX_LANGUAGES 3
|
|
||||||
|
|
||||||
// Textos
|
|
||||||
#define MAX_TEXT_STRINGS 100
|
|
||||||
|
|
||||||
// Clase Lang
|
|
||||||
class Lang
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
Asset *mAsset;
|
|
||||||
std::string mTextStrings[MAX_TEXT_STRINGS];
|
|
||||||
|
|
||||||
public:
|
|
||||||
// Constructor
|
|
||||||
Lang(Asset *asset);
|
|
||||||
|
|
||||||
// Destructor
|
|
||||||
~Lang();
|
|
||||||
|
|
||||||
// Inicializa los textos del juego en el idioma seleccionado
|
|
||||||
bool setLang(Uint8 lang);
|
|
||||||
|
|
||||||
// Obtiene la cadena de texto del indice
|
|
||||||
std::string getText(int index);
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
@@ -63,7 +63,7 @@ Player::~Player()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Pinta el enemigo en pantalla
|
// Pinta el enemigo en pantalla
|
||||||
void Player::draw()
|
void Player::render()
|
||||||
{
|
{
|
||||||
sprite->getTexture()->setColor(color.r, color.g, color.b);
|
sprite->getTexture()->setColor(color.r, color.g, color.b);
|
||||||
sprite->render();
|
sprite->render();
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ public:
|
|||||||
~Player();
|
~Player();
|
||||||
|
|
||||||
// Pinta el enemigo en pantalla
|
// Pinta el enemigo en pantalla
|
||||||
void draw();
|
void render();
|
||||||
|
|
||||||
// Actualiza las variables del objeto
|
// Actualiza las variables del objeto
|
||||||
void update();
|
void update();
|
||||||
|
|||||||
@@ -375,14 +375,12 @@ void Room::fillMapTexture()
|
|||||||
|
|
||||||
// Los tilesets son de 20x20 tiles. El primer tile es el 1. Cuentan hacia la derecha y hacia abajo
|
// Los tilesets son de 20x20 tiles. El primer tile es el 1. Cuentan hacia la derecha y hacia abajo
|
||||||
|
|
||||||
// printf("Filling map\n");
|
|
||||||
SDL_Rect clip = {0, 0, 8, 8};
|
SDL_Rect clip = {0, 0, 8, 8};
|
||||||
for (int y = 0; y < 16; y++)
|
for (int y = 0; y < 16; y++)
|
||||||
for (int x = 0; x < 32; x++)
|
for (int x = 0; x < 32; x++)
|
||||||
{
|
{
|
||||||
clip.x = ((tilemap[(y * 32) + x] - 1) % 20) * 8;
|
clip.x = ((tilemap[(y * 32) + x] - 1) % 20) * 8;
|
||||||
clip.y = ((tilemap[(y * 32) + x] - 1) / 20) * 8;
|
clip.y = ((tilemap[(y * 32) + x] - 1) / 20) * 8;
|
||||||
// printf("tilemap [%i] = %i | x = %i | y = %i\n", ((y * 32) + x), tilemap[(y * 32) + x], clip.x, clip.y);
|
|
||||||
texture->render(renderer, x * 8, y * 8, &clip);
|
texture->render(renderer, x * 8, y * 8, &clip);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -390,7 +388,7 @@ void Room::fillMapTexture()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Dibuja el mapa en pantalla
|
// Dibuja el mapa en pantalla
|
||||||
void Room::drawMap()
|
void Room::renderMap()
|
||||||
{
|
{
|
||||||
SDL_Rect rect = {0, 0, GAMECANVAS_WIDTH, GAMECANVAS_HEIGHT};
|
SDL_Rect rect = {0, 0, GAMECANVAS_WIDTH, GAMECANVAS_HEIGHT};
|
||||||
|
|
||||||
@@ -399,20 +397,20 @@ void Room::drawMap()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Dibuja los enemigos en pantalla
|
// Dibuja los enemigos en pantalla
|
||||||
void Room::drawEnemies()
|
void Room::renderEnemies()
|
||||||
{
|
{
|
||||||
for (auto enemy : enemies)
|
for (auto enemy : enemies)
|
||||||
{
|
{
|
||||||
enemy->draw();
|
enemy->render();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dibuja los objetos en pantalla
|
// Dibuja los objetos en pantalla
|
||||||
void Room::drawItems()
|
void Room::renderItems()
|
||||||
{
|
{
|
||||||
for (auto item : items)
|
for (auto item : items)
|
||||||
{
|
{
|
||||||
item->draw();
|
item->render();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -80,13 +80,13 @@ public:
|
|||||||
color_t getBGColor();
|
color_t getBGColor();
|
||||||
|
|
||||||
// Dibuja el mapa en pantalla
|
// Dibuja el mapa en pantalla
|
||||||
void drawMap();
|
void renderMap();
|
||||||
|
|
||||||
// Dibuja los enemigos en pantalla
|
// Dibuja los enemigos en pantalla
|
||||||
void drawEnemies();
|
void renderEnemies();
|
||||||
|
|
||||||
// Dibuja los objetos en pantalla
|
// Dibuja los objetos en pantalla
|
||||||
void drawItems();
|
void renderItems();
|
||||||
|
|
||||||
// Actualiza las variables y objetos de la habitación
|
// Actualiza las variables y objetos de la habitación
|
||||||
void update();
|
void update();
|
||||||
|
|||||||
@@ -1,158 +0,0 @@
|
|||||||
#include "const.h"
|
|
||||||
#include "writer.h"
|
|
||||||
|
|
||||||
// Constructor
|
|
||||||
Writer::Writer(Text *text)
|
|
||||||
{
|
|
||||||
mText = text;
|
|
||||||
init();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Destructor
|
|
||||||
Writer::~Writer()
|
|
||||||
{
|
|
||||||
mText = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Inicializador
|
|
||||||
void Writer::init()
|
|
||||||
{
|
|
||||||
mPosX = 0;
|
|
||||||
mPosY = 0;
|
|
||||||
mKerning = 0;
|
|
||||||
mCaption = "";
|
|
||||||
mSpeed = 0;
|
|
||||||
mTimer = 0;
|
|
||||||
mIndex = 0;
|
|
||||||
mLenght = 0;
|
|
||||||
mCompleted = false;
|
|
||||||
mEnabled = false;
|
|
||||||
mEnabledTimer = 0;
|
|
||||||
mId = -1;
|
|
||||||
mIntroEvents = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Establece el valor de la variable
|
|
||||||
void Writer::setPosX(int value)
|
|
||||||
{
|
|
||||||
mPosX = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Establece el valor de la variable
|
|
||||||
void Writer::setPosY(int value)
|
|
||||||
{
|
|
||||||
mPosY = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Establece el valor de la variable
|
|
||||||
void Writer::setKerning(int value)
|
|
||||||
{
|
|
||||||
mKerning = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Establece el valor de la variable
|
|
||||||
void Writer::setCaption(std::string text)
|
|
||||||
{
|
|
||||||
mCaption = text;
|
|
||||||
mLenght = text.length();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Establece el valor de la variable
|
|
||||||
void Writer::setSpeed(Uint16 value)
|
|
||||||
{
|
|
||||||
mSpeed = value;
|
|
||||||
mTimer = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Establece el valor de la variable
|
|
||||||
void Writer::setEnabled(bool value)
|
|
||||||
{
|
|
||||||
mEnabled = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Obtiene el valor de la variable
|
|
||||||
bool Writer::IsEnabled()
|
|
||||||
{
|
|
||||||
return mEnabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Establece el valor de la variable
|
|
||||||
void Writer::setEnabledTimer(Uint16 value)
|
|
||||||
{
|
|
||||||
mEnabledTimer = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Obtiene el valor de la variable
|
|
||||||
Uint16 Writer::getEnabledTimer()
|
|
||||||
{
|
|
||||||
return mEnabledTimer;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Actualiza el objeto
|
|
||||||
void Writer::update()
|
|
||||||
{
|
|
||||||
if (mEnabled)
|
|
||||||
{
|
|
||||||
if (mCompleted == false)
|
|
||||||
{
|
|
||||||
if (mTimer > 0)
|
|
||||||
{
|
|
||||||
mTimer--;
|
|
||||||
}
|
|
||||||
if (mTimer == 0)
|
|
||||||
{
|
|
||||||
mIndex++;
|
|
||||||
mTimer = mSpeed;
|
|
||||||
}
|
|
||||||
if (mIndex == mLenght)
|
|
||||||
{
|
|
||||||
mCompleted = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (mCompleted)
|
|
||||||
{
|
|
||||||
if (mEnabledTimer > 0)
|
|
||||||
{
|
|
||||||
mEnabledTimer--;
|
|
||||||
}
|
|
||||||
else if (mEnabledTimer == 0)
|
|
||||||
{
|
|
||||||
if (mId < 0)
|
|
||||||
{
|
|
||||||
mEnabled = false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mIntroEvents[mId] = EVENT_COMPLETED;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Dibuja el objeto en pantalla
|
|
||||||
void Writer::render()
|
|
||||||
{
|
|
||||||
if (mEnabled)
|
|
||||||
{
|
|
||||||
mText->write(mPosX, mPosY, mCaption, mKerning, mIndex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Centra la cadena de texto a un punto X
|
|
||||||
void Writer::center(int x)
|
|
||||||
{
|
|
||||||
setPosX(x - (mText->lenght(mCaption, mKerning) / 2));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Establece el valor de la variable
|
|
||||||
void Writer::setId(int id)
|
|
||||||
{
|
|
||||||
mId = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Establece el valor de la variable
|
|
||||||
void Writer::setIntroEvents(Uint8 *value)
|
|
||||||
{
|
|
||||||
mIntroEvents = value;
|
|
||||||
}
|
|
||||||
@@ -1,80 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include "sprite.h"
|
|
||||||
#include "text.h"
|
|
||||||
|
|
||||||
#ifndef WRITER_H
|
|
||||||
#define WRITER_H
|
|
||||||
|
|
||||||
// Clase texto. Pinta texto en pantalla a partir de un bitmap
|
|
||||||
class Writer
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
int mPosX; // Posicion en el eje X donde empezar a escribir el texto
|
|
||||||
int mPosY; // Posicion en el eje Y donde empezar a escribir el texto
|
|
||||||
int mKerning; // Kerning del texto, es decir, espaciado entre caracteres
|
|
||||||
std::string mCaption; // El texto para escribir
|
|
||||||
Uint16 mSpeed; // Velocidad de escritura
|
|
||||||
Uint16 mTimer; // Temporizador de escritura para cada caracter
|
|
||||||
Uint16 mIndex; // Posición del texto que se está escribiendo
|
|
||||||
Uint16 mLenght; // Longitud de la cadena a escribir
|
|
||||||
bool mCompleted; // Indica si se ha escrito todo el texto
|
|
||||||
bool mEnabled; // Indica si el objeto está habilitado
|
|
||||||
Uint16 mEnabledTimer; // Temporizador para deshabilitar el objeto
|
|
||||||
int mId; // Temporizador para deshabilitar el objeto
|
|
||||||
Uint8 *mIntroEvents; // Dirección del array de eventos donde notificar el estado
|
|
||||||
Text *mText; // Objeto encargado de escribir el texto
|
|
||||||
|
|
||||||
public:
|
|
||||||
// Constructor
|
|
||||||
Writer(Text *text);
|
|
||||||
|
|
||||||
// Destructor
|
|
||||||
~Writer();
|
|
||||||
|
|
||||||
// Inicializador
|
|
||||||
void init();
|
|
||||||
|
|
||||||
// Establece el valor de la variable
|
|
||||||
void setPosX(int value);
|
|
||||||
|
|
||||||
// Establece el valor de la variable
|
|
||||||
void setPosY(int value);
|
|
||||||
|
|
||||||
// Establece el valor de la variable
|
|
||||||
void setKerning(int value);
|
|
||||||
|
|
||||||
// Establece el valor de la variable
|
|
||||||
void setCaption(std::string text);
|
|
||||||
|
|
||||||
// Establece el valor de la variable
|
|
||||||
void setSpeed(Uint16 value);
|
|
||||||
|
|
||||||
// Establece el valor de la variable
|
|
||||||
void setEnabled(bool value);
|
|
||||||
|
|
||||||
// Obtiene el valor de la variable
|
|
||||||
bool IsEnabled();
|
|
||||||
|
|
||||||
// Establece el valor de la variable
|
|
||||||
void setEnabledTimer(Uint16 value);
|
|
||||||
|
|
||||||
// Obtiene el valor de la variable
|
|
||||||
Uint16 getEnabledTimer();
|
|
||||||
|
|
||||||
// Actualiza el objeto
|
|
||||||
void update();
|
|
||||||
|
|
||||||
// Dibuja el objeto en pantalla
|
|
||||||
void render();
|
|
||||||
|
|
||||||
// Centra la cadena de texto a un punto X
|
|
||||||
void center(int x);
|
|
||||||
|
|
||||||
// Establece el valor de la variable
|
|
||||||
void setId(int id);
|
|
||||||
|
|
||||||
// Establece el valor de la variable
|
|
||||||
void setIntroEvents(Uint8 *value);
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
46
todo.md
Normal file
46
todo.md
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
## TAREAS
|
||||||
|
(A) Hacer que deje de poder moverse tras el salto al alcanzar la misma posicion en altura que tenia cuando saltó {cm:2022-08-29}
|
||||||
|
(A) Arreglar que no atraviese tiles atravaseables al caer muy rapido {cm:2022-08-29}
|
||||||
|
(A) Leer los mapas directamente del archivo tmx {cm:2022-08-29}
|
||||||
|
(A) Crear la clase item {cm:2022-08-29}
|
||||||
|
(A) Colisiones con los enemigos {cm:2022-08-29}
|
||||||
|
(A) Decidir un diseño para qué sucede en caso de morir: Recordar el punto por donde se entró al mapa y la velocidad en el eje X/Y que llevaba el personaje, crear puntos de reaparicion en las habitaciones, etc {cm:2022-08-29}
|
||||||
|
En el Jet Set Willy el juego recuerda la posicion y el momento. En las Tres Luces de Glaurung solo la posición. Se va a optar por seguir el diseño del Jet Set Willy {cm:2022-08-29}
|
||||||
|
(A) Crear tiles que maten {cm:2022-08-29}
|
||||||
|
(A) Crear tiles que deslicen, (no tipo hielo sino cinta)
|
||||||
|
(A) Tiles animados
|
||||||
|
(A) Crear ascensores
|
||||||
|
(A) Enemigos de diferente tamaño
|
||||||
|
(A) Color de los items
|
||||||
|
(A) Temporizador de inicio de los items
|
||||||
|
|
||||||
|
|
||||||
|
## TEMAS
|
||||||
|
arounders
|
||||||
|
paku simbel
|
||||||
|
jail battle
|
||||||
|
arounders race
|
||||||
|
aee gba
|
||||||
|
matatunos
|
||||||
|
sigmasua
|
||||||
|
calculin doom
|
||||||
|
leaper reaper
|
||||||
|
mini ascii
|
||||||
|
mappy
|
||||||
|
paco
|
||||||
|
chirping
|
||||||
|
abad y batman
|
||||||
|
jail
|
||||||
|
counter strike
|
||||||
|
starcraft
|
||||||
|
diablo
|
||||||
|
jailparty
|
||||||
|
maniac mansion
|
||||||
|
molotov
|
||||||
|
tutorials
|
||||||
|
gavina
|
||||||
|
puzzle restorer
|
||||||
|
qvoid
|
||||||
|
brick roll
|
||||||
|
dante's fall
|
||||||
|
repairing computers
|
||||||
45
todo.txt
45
todo.txt
@@ -1,45 +0,0 @@
|
|||||||
[x] Hacer que deje de poder moverse tras el salto al alcanzar la misma posicion en altura que tenia cuando saltó
|
|
||||||
[x] Arreglar que no atraviese tiles atravaseables al caer muy rapido
|
|
||||||
[x] Leer los mapas directamente del archivo tmx
|
|
||||||
[x] Crear la clase item
|
|
||||||
[x] Colisiones con los enemigos
|
|
||||||
[x] Decidir un diseño para qué sucede en caso de morir: Recordar el punto por donde se entró al mapa y la velocidad en el eje X/Y que llevaba el personaje, crear puntos de reaparicion en las habitaciones, etc
|
|
||||||
En el Jet Set Willy el juego recuerda la posicion y el momento. En las Tres Luces de Glaurung solo la posición. Se va a optar por seguir el diseño del Jet Set Willy
|
|
||||||
[x] Crear tiles que maten
|
|
||||||
[ ] Crear tiles que deslicen, (no tipo hielo sino cinta)
|
|
||||||
[ ] Tiles animados
|
|
||||||
[ ] Crear ascensores
|
|
||||||
[ ] Enemigos de diferente tamaño
|
|
||||||
[ ] Color de los items
|
|
||||||
[ ] Temporizador de inicio de los items
|
|
||||||
|
|
||||||
|
|
||||||
TEMAS:
|
|
||||||
arounders
|
|
||||||
paku simbel
|
|
||||||
jail battle
|
|
||||||
arounders race
|
|
||||||
aee gba
|
|
||||||
matatunos
|
|
||||||
sigmasua
|
|
||||||
calculin doom
|
|
||||||
leaper reaper
|
|
||||||
mini ascii
|
|
||||||
mappy
|
|
||||||
paco
|
|
||||||
chirping
|
|
||||||
abad y batman
|
|
||||||
jail
|
|
||||||
counter strike
|
|
||||||
starcraft
|
|
||||||
diablo
|
|
||||||
jailparty
|
|
||||||
maniac mansion
|
|
||||||
molotov
|
|
||||||
tutorials
|
|
||||||
gavina
|
|
||||||
puzzle restorer
|
|
||||||
qvoid
|
|
||||||
brick roll
|
|
||||||
dante's fall
|
|
||||||
repairing computers
|
|
||||||
Reference in New Issue
Block a user