Arreglada la calse text
This commit is contained in:
BIN
data/music.ogg
Normal file
BIN
data/music.ogg
Normal file
Binary file not shown.
BIN
data/smb2.png
Normal file
BIN
data/smb2.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.4 KiB |
194
data/smb2.txt
Normal file
194
data/smb2.txt
Normal file
@@ -0,0 +1,194 @@
|
|||||||
|
# box width
|
||||||
|
8
|
||||||
|
# box height
|
||||||
|
8
|
||||||
|
# 32 espacio ( )
|
||||||
|
7
|
||||||
|
# 33 !
|
||||||
|
7
|
||||||
|
# 34 "
|
||||||
|
7
|
||||||
|
# 35 #
|
||||||
|
7
|
||||||
|
# 36 $
|
||||||
|
7
|
||||||
|
# 37 %
|
||||||
|
7
|
||||||
|
# 38 &
|
||||||
|
7
|
||||||
|
# 39 '
|
||||||
|
7
|
||||||
|
# 40 (
|
||||||
|
7
|
||||||
|
# 41 )
|
||||||
|
7
|
||||||
|
# 42 *
|
||||||
|
7
|
||||||
|
# 43 +
|
||||||
|
7
|
||||||
|
# 44 ,
|
||||||
|
7
|
||||||
|
# 45 -
|
||||||
|
7
|
||||||
|
# 46 .
|
||||||
|
7
|
||||||
|
# 47 /
|
||||||
|
7
|
||||||
|
# 48 0
|
||||||
|
7
|
||||||
|
# 49 1
|
||||||
|
7
|
||||||
|
# 50 2
|
||||||
|
7
|
||||||
|
# 51 3
|
||||||
|
7
|
||||||
|
# 52 4
|
||||||
|
7
|
||||||
|
# 53 5
|
||||||
|
7
|
||||||
|
# 54 6
|
||||||
|
7
|
||||||
|
# 55 7
|
||||||
|
7
|
||||||
|
# 56 8
|
||||||
|
7
|
||||||
|
# 57 9
|
||||||
|
7
|
||||||
|
# 58 :
|
||||||
|
7
|
||||||
|
# 59 ;
|
||||||
|
7
|
||||||
|
# 60 <
|
||||||
|
7
|
||||||
|
# 61 =
|
||||||
|
7
|
||||||
|
# 62 >
|
||||||
|
7
|
||||||
|
# 63 ?
|
||||||
|
7
|
||||||
|
# 64 @
|
||||||
|
7
|
||||||
|
# 65 A
|
||||||
|
7
|
||||||
|
# 66 B
|
||||||
|
7
|
||||||
|
# 67 C
|
||||||
|
7
|
||||||
|
# 68 D
|
||||||
|
7
|
||||||
|
# 69 E
|
||||||
|
7
|
||||||
|
# 70 F
|
||||||
|
7
|
||||||
|
# 71 G
|
||||||
|
7
|
||||||
|
# 72 H
|
||||||
|
7
|
||||||
|
# 73 I
|
||||||
|
7
|
||||||
|
# 74 J
|
||||||
|
7
|
||||||
|
# 75 K
|
||||||
|
7
|
||||||
|
# 76 L
|
||||||
|
7
|
||||||
|
# 77 M
|
||||||
|
7
|
||||||
|
# 78 N
|
||||||
|
7
|
||||||
|
# 79 O
|
||||||
|
7
|
||||||
|
# 80 P
|
||||||
|
7
|
||||||
|
# 81 Q
|
||||||
|
7
|
||||||
|
# 82 R
|
||||||
|
7
|
||||||
|
# 83 S
|
||||||
|
7
|
||||||
|
# 84 T
|
||||||
|
7
|
||||||
|
# 85 U
|
||||||
|
7
|
||||||
|
# 86 V
|
||||||
|
7
|
||||||
|
# 87 W
|
||||||
|
7
|
||||||
|
# 88 X
|
||||||
|
7
|
||||||
|
# 89 Y
|
||||||
|
7
|
||||||
|
# 90 Z
|
||||||
|
7
|
||||||
|
# 91 [
|
||||||
|
7
|
||||||
|
# 92 \
|
||||||
|
7
|
||||||
|
# 93 ]
|
||||||
|
7
|
||||||
|
# 94 ^
|
||||||
|
7
|
||||||
|
# 95 _
|
||||||
|
7
|
||||||
|
# 96 `
|
||||||
|
7
|
||||||
|
# 97 a
|
||||||
|
7
|
||||||
|
# 98 b
|
||||||
|
7
|
||||||
|
# 99 c
|
||||||
|
7
|
||||||
|
# 100 d
|
||||||
|
7
|
||||||
|
# 101 e
|
||||||
|
7
|
||||||
|
# 102 f
|
||||||
|
7
|
||||||
|
# 103 g
|
||||||
|
7
|
||||||
|
# 104 h
|
||||||
|
7
|
||||||
|
# 105 i
|
||||||
|
7
|
||||||
|
# 106 j
|
||||||
|
7
|
||||||
|
# 107 k
|
||||||
|
7
|
||||||
|
# 108 l
|
||||||
|
7
|
||||||
|
# 109 m
|
||||||
|
7
|
||||||
|
# 110 n
|
||||||
|
7
|
||||||
|
# 111 o
|
||||||
|
7
|
||||||
|
# 112 p
|
||||||
|
7
|
||||||
|
# 113 q
|
||||||
|
7
|
||||||
|
# 114 r
|
||||||
|
7
|
||||||
|
# 115 s
|
||||||
|
7
|
||||||
|
# 116 t
|
||||||
|
7
|
||||||
|
# 117 u
|
||||||
|
7
|
||||||
|
# 118 v
|
||||||
|
7
|
||||||
|
# 119 w
|
||||||
|
7
|
||||||
|
# 120 x
|
||||||
|
7
|
||||||
|
# 121 y
|
||||||
|
7
|
||||||
|
# 122 z
|
||||||
|
7
|
||||||
|
# 123 {
|
||||||
|
7
|
||||||
|
# 124 |
|
||||||
|
7
|
||||||
|
# 125 }
|
||||||
|
7
|
||||||
|
# 126 ~
|
||||||
|
7
|
||||||
BIN
data/sound.wav
Normal file
BIN
data/sound.wav
Normal file
Binary file not shown.
94
main.cpp
Normal file
94
main.cpp
Normal file
@@ -0,0 +1,94 @@
|
|||||||
|
/*
|
||||||
|
|
||||||
|
Ejemplo de uso de las unidades incluídas en jail_engine
|
||||||
|
Código fuente creado por JailDesigner
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <SDL2/SDL.h>
|
||||||
|
#include <iostream>
|
||||||
|
#include "units/jail_audio.h"
|
||||||
|
#include "units/text.h"
|
||||||
|
#include "units/utils.h"
|
||||||
|
|
||||||
|
SDL_Event *event;
|
||||||
|
SDL_Window *window;
|
||||||
|
SDL_Renderer *renderer;
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
|
||||||
|
// Inicializa las opciones
|
||||||
|
struct options_t *options = new options_t;
|
||||||
|
options->gameWidth = 640;
|
||||||
|
options->gameHeight = 480;
|
||||||
|
|
||||||
|
// Inicializa SDL y la ventana
|
||||||
|
SDL_Init(SDL_INIT_EVERYTHING);
|
||||||
|
window = SDL_CreateWindow("jail_engine_demo", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, options->gameWidth, options->gameHeight, SDL_WINDOW_SHOWN);
|
||||||
|
if (window != nullptr)
|
||||||
|
{
|
||||||
|
renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);
|
||||||
|
}
|
||||||
|
event = new SDL_Event();
|
||||||
|
|
||||||
|
// Inicializa jail_audio
|
||||||
|
JA_Init(48000, AUDIO_S16, 2);
|
||||||
|
|
||||||
|
JA_Music_t *music;
|
||||||
|
JA_Sound_t *peiv;
|
||||||
|
|
||||||
|
music = JA_LoadMusic("data/music.ogg");
|
||||||
|
peiv = JA_LoadSound("data/sound.wav");
|
||||||
|
int volume = 128;
|
||||||
|
|
||||||
|
// Inicializa el texto
|
||||||
|
Text *text = new Text("data/smb2.txt", "data/smb2.png", renderer);
|
||||||
|
|
||||||
|
// Bucle principal
|
||||||
|
JA_PlayMusic(music, true);
|
||||||
|
bool should_exit = false;
|
||||||
|
while (!should_exit)
|
||||||
|
{
|
||||||
|
|
||||||
|
// Actualiza la lógica del programa
|
||||||
|
while (SDL_PollEvent(event))
|
||||||
|
{
|
||||||
|
if (event->type == SDL_QUIT)
|
||||||
|
{
|
||||||
|
should_exit = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (event->type == SDL_KEYDOWN)
|
||||||
|
{
|
||||||
|
switch (event->key.keysym.scancode)
|
||||||
|
{
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Dibuja en pantalla
|
||||||
|
SDL_SetRenderDrawColor(renderer, 0x00, 0x00, 0x00, 0xFF);
|
||||||
|
SDL_RenderClear(renderer);
|
||||||
|
text->writeCentered(options->gameWidth / 2 ,text->getCharacterSize(),"Jail Engine DEMO");
|
||||||
|
SDL_RenderPresent(renderer);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Finaliza el texto
|
||||||
|
delete text;
|
||||||
|
|
||||||
|
// Finaliza jail_audio
|
||||||
|
JA_DeleteSound(peiv);
|
||||||
|
JA_DeleteMusic(music);
|
||||||
|
|
||||||
|
// Finaliza SDL y la ventana
|
||||||
|
SDL_DestroyRenderer(renderer);
|
||||||
|
SDL_DestroyWindow(window);
|
||||||
|
delete event;
|
||||||
|
SDL_Quit();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
337
resource.cpp
337
resource.cpp
@@ -1,337 +0,0 @@
|
|||||||
#include "resource.h"
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
// Constructor
|
|
||||||
Resource::Resource(SDL_Renderer *renderer, Asset *asset, options_t *options)
|
|
||||||
{
|
|
||||||
this->renderer = renderer;
|
|
||||||
this->asset = asset;
|
|
||||||
this->options = options;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Carga las texturas de una lista
|
|
||||||
void Resource::loadTextures(std::vector<std::string> list)
|
|
||||||
{
|
|
||||||
for (auto l : list)
|
|
||||||
{
|
|
||||||
if (options->console)
|
|
||||||
{
|
|
||||||
std::cout << "\nLOAD TEXTURE: " << l << std::endl;
|
|
||||||
std::cout << "png: " << asset->get(l) << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
res_texture_t t;
|
|
||||||
t.name = l;
|
|
||||||
t.texture = new Texture(renderer, asset->get(t.name), options->console);
|
|
||||||
textures.push_back(t);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Vuelve a cargar las texturas
|
|
||||||
void Resource::reLoadTextures()
|
|
||||||
{
|
|
||||||
for (auto texture : textures)
|
|
||||||
{
|
|
||||||
texture.texture->reLoad();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Carga las animaciones desde una lista
|
|
||||||
void Resource::loadAnimations(std::vector<std::string> list)
|
|
||||||
{
|
|
||||||
for (auto l : list)
|
|
||||||
{
|
|
||||||
// Extrae el nombre del fichero sin la extension para crear el nombre del fichero de la textura
|
|
||||||
const std::string pngFile = l.substr(0, l.find_last_of(".")) + ".png";
|
|
||||||
|
|
||||||
if (options->console)
|
|
||||||
{
|
|
||||||
std::cout << "\nLOAD ANIMATION: " << l << std::endl;
|
|
||||||
std::cout << "png: " << asset->get(pngFile) << std::endl;
|
|
||||||
std::cout << "ani: " << asset->get(l) << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
res_animation_t as;
|
|
||||||
as.name = l;
|
|
||||||
as.animation = new animatedSprite_t(loadAnimationFromFile(getTexture(pngFile), asset->get(as.name), options->console));
|
|
||||||
animations.push_back(as);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Vuelve a cargar las animaciones
|
|
||||||
void Resource::reLoadAnimations()
|
|
||||||
{
|
|
||||||
// reLoadTextures();
|
|
||||||
|
|
||||||
for (auto &a : animations)
|
|
||||||
{
|
|
||||||
// Extrae el nombre del fichero sin la extension para crear el nombre del fichero de la textura
|
|
||||||
const std::string pngFile = a.name.substr(0, a.name.find_last_of(".")) + ".png";
|
|
||||||
delete a.animation;
|
|
||||||
a.animation = new animatedSprite_t(loadAnimationFromFile(getTexture(pngFile), asset->get(a.name), options->console));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Carga los offsets desde una lista
|
|
||||||
void Resource::loadOffsets(std::vector<std::string> list)
|
|
||||||
{
|
|
||||||
for (auto l : list)
|
|
||||||
{
|
|
||||||
res_textOffset_t to;
|
|
||||||
to.name = l;
|
|
||||||
to.textFile = new textFile_t(LoadTextFile(asset->get(l), options->console));
|
|
||||||
offsets.push_back(to);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Vuelve a cargar los offsets
|
|
||||||
void Resource::reLoadOffsets()
|
|
||||||
{
|
|
||||||
for (auto &o : offsets)
|
|
||||||
{
|
|
||||||
delete o.textFile;
|
|
||||||
o.textFile = new textFile_t(LoadTextFile(asset->get(o.name), options->console));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Carga los mapas de tiles desde una lista
|
|
||||||
void Resource::loadTileMaps(std::vector<std::string> list)
|
|
||||||
{
|
|
||||||
for (auto l : list)
|
|
||||||
{
|
|
||||||
res_tileMap_t tm;
|
|
||||||
tm.name = l;
|
|
||||||
tm.tileMap = new std::vector<int>(loadRoomTileFile(asset->get(l), options->console));
|
|
||||||
tileMaps.push_back(tm);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Vuelve a cargar los mapas de tiles
|
|
||||||
void Resource::reLoadTileMaps()
|
|
||||||
{
|
|
||||||
for (auto &tm : tileMaps)
|
|
||||||
{
|
|
||||||
delete tm.tileMap;
|
|
||||||
tm.tileMap = new std::vector<int>(loadRoomTileFile(asset->get(tm.name), options->console));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Carga las habitaciones desde una lista
|
|
||||||
void Resource::loadRooms(std::vector<std::string> list)
|
|
||||||
{
|
|
||||||
for (auto l : list)
|
|
||||||
{
|
|
||||||
res_room_t r;
|
|
||||||
r.name = l;
|
|
||||||
r.room = new room_t(loadRoomFile(asset->get(l), options->console));
|
|
||||||
r.room->tileMap = getTileMap(r.room->tileMapFile);
|
|
||||||
for (auto &e : r.room->enemies)
|
|
||||||
{
|
|
||||||
e.animation = getAnimation(e.animationString);
|
|
||||||
}
|
|
||||||
for (auto &i : r.room->items)
|
|
||||||
{
|
|
||||||
i.texture = getTexture(i.tileSetFile);
|
|
||||||
}
|
|
||||||
r.room->textureA = getTexture("standard.png");
|
|
||||||
r.room->textureB = getTexture("standard_zxarne.png");
|
|
||||||
rooms.push_back(r);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Vuelve a cargar las habitaciones
|
|
||||||
void Resource::reLoadRooms()
|
|
||||||
{
|
|
||||||
reLoadTileMaps();
|
|
||||||
|
|
||||||
for (auto &r : rooms)
|
|
||||||
{
|
|
||||||
delete r.room;
|
|
||||||
r.room = new room_t(loadRoomFile(asset->get(r.name)));
|
|
||||||
r.room->tileMap = getTileMap(r.room->tileMapFile);
|
|
||||||
for (auto &e : r.room->enemies)
|
|
||||||
{
|
|
||||||
e.animation = getAnimation(e.animationString);
|
|
||||||
}
|
|
||||||
for (auto &i : r.room->items)
|
|
||||||
{
|
|
||||||
i.texture = getTexture(i.tileSetFile);
|
|
||||||
}
|
|
||||||
r.room->textureA = getTexture("standard.png");
|
|
||||||
r.room->textureB = getTexture("standard_zxarne.png");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Vuelve a cargar todos los recursos
|
|
||||||
void Resource::reLoad()
|
|
||||||
{
|
|
||||||
reLoadAnimations();
|
|
||||||
reLoadOffsets();
|
|
||||||
reLoadRooms();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Libera las texturas
|
|
||||||
void Resource::freeTextures()
|
|
||||||
{
|
|
||||||
for (auto texture : textures)
|
|
||||||
{
|
|
||||||
delete texture.texture;
|
|
||||||
}
|
|
||||||
textures.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Libera las animaciones
|
|
||||||
void Resource::freeAnimations()
|
|
||||||
{
|
|
||||||
for (auto a : animations)
|
|
||||||
{
|
|
||||||
delete a.animation;
|
|
||||||
}
|
|
||||||
animations.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Libera los offsets
|
|
||||||
void Resource::freeOffsets()
|
|
||||||
{
|
|
||||||
for (auto o : offsets)
|
|
||||||
{
|
|
||||||
delete o.textFile;
|
|
||||||
}
|
|
||||||
offsets.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Libera los mapas de tiles
|
|
||||||
void Resource::freeTileMaps()
|
|
||||||
{
|
|
||||||
for (auto t : tileMaps)
|
|
||||||
{
|
|
||||||
delete t.tileMap;
|
|
||||||
}
|
|
||||||
tileMaps.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Libera las habitaciones
|
|
||||||
void Resource::freeRooms()
|
|
||||||
{
|
|
||||||
for (auto r : rooms)
|
|
||||||
{
|
|
||||||
delete r.room;
|
|
||||||
}
|
|
||||||
rooms.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Libera todos los recursos
|
|
||||||
void Resource::free()
|
|
||||||
{
|
|
||||||
freeTextures();
|
|
||||||
freeAnimations();
|
|
||||||
freeOffsets();
|
|
||||||
freeTileMaps();
|
|
||||||
freeRooms();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Obtiene una textura
|
|
||||||
Texture *Resource::getTexture(std::string name)
|
|
||||||
{
|
|
||||||
for (auto texture : textures)
|
|
||||||
{
|
|
||||||
// if (texture.name.find(name) != std::string::npos)
|
|
||||||
if (texture.name == name)
|
|
||||||
{
|
|
||||||
// std::cout << "\nTEXTURE REQUESTED: " << name << std::endl;
|
|
||||||
// std::cout << "served: " << texture.name << std::endl;
|
|
||||||
|
|
||||||
return texture.texture;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (options->console)
|
|
||||||
{
|
|
||||||
std::cout << "NOT FOUND ON CACHE: " << name << std::endl;
|
|
||||||
}
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Obtiene una animación
|
|
||||||
animatedSprite_t *Resource::getAnimation(std::string name)
|
|
||||||
{
|
|
||||||
for (auto animation : animations)
|
|
||||||
{
|
|
||||||
// if (animation.name.find(name) != std::string::npos)
|
|
||||||
if (animation.name == name)
|
|
||||||
{
|
|
||||||
// std::cout << "\nANIMATION REQUESTED: " << name << std::endl;
|
|
||||||
// std::cout << "served: " << animation.name << std::endl;
|
|
||||||
return animation.animation;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (options->console)
|
|
||||||
{
|
|
||||||
std::cout << "NOT FOUND ON CACHE: " << name << std::endl;
|
|
||||||
}
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Obtiene un offset
|
|
||||||
textFile_t *Resource::getOffset(std::string name)
|
|
||||||
{
|
|
||||||
for (auto offset : offsets)
|
|
||||||
{
|
|
||||||
// if (offset.name.find(name) != std::string::npos)
|
|
||||||
if (offset.name == name)
|
|
||||||
{
|
|
||||||
return offset.textFile;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (options->console)
|
|
||||||
{
|
|
||||||
std::cout << "NOT FOUND ON CACHE: " << name << std::endl;
|
|
||||||
}
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Obtiene un mapa de tiles
|
|
||||||
std::vector<int> *Resource::getTileMap(std::string name)
|
|
||||||
{
|
|
||||||
for (auto tileMap : tileMaps)
|
|
||||||
{
|
|
||||||
// if (tileMap.name.find(name) != std::string::npos)
|
|
||||||
if (tileMap.name == name)
|
|
||||||
{
|
|
||||||
return tileMap.tileMap;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (options->console)
|
|
||||||
{
|
|
||||||
std::cout << "NOT FOUND ON CACHE: " << name << std::endl;
|
|
||||||
}
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Obtiene una habitacion
|
|
||||||
room_t *Resource::getRoom(std::string name)
|
|
||||||
{
|
|
||||||
for (auto room : rooms)
|
|
||||||
{
|
|
||||||
// if (room.name.find(name) != std::string::npos)
|
|
||||||
if (room.name == name)
|
|
||||||
{
|
|
||||||
return room.room;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (options->console)
|
|
||||||
{
|
|
||||||
std::cout << "NOT FOUND ON CACHE: " << name << std::endl;
|
|
||||||
}
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Obtiene todas las habitaciones
|
|
||||||
std::vector<res_room_t> *Resource::getAllRooms()
|
|
||||||
{
|
|
||||||
return &rooms;
|
|
||||||
}
|
|
||||||
136
resource.h
136
resource.h
@@ -1,136 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include <SDL2/SDL.h>
|
|
||||||
#include "animatedsprite.h"
|
|
||||||
#include "asset.h"
|
|
||||||
#include "../room.h"
|
|
||||||
#include "text.h"
|
|
||||||
#include "texture.h"
|
|
||||||
#include "utils.h"
|
|
||||||
#include <string>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
#ifndef RESOURCE_H
|
|
||||||
#define RESOURCE_H
|
|
||||||
|
|
||||||
struct res_texture_t
|
|
||||||
{
|
|
||||||
std::string name; // Nombre de la textura
|
|
||||||
Texture *texture; // La textura
|
|
||||||
};
|
|
||||||
|
|
||||||
struct res_animation_t
|
|
||||||
{
|
|
||||||
std::string name; // Nombre de la textura
|
|
||||||
animatedSprite_t *animation; // La animación
|
|
||||||
};
|
|
||||||
|
|
||||||
struct res_textOffset_t
|
|
||||||
{
|
|
||||||
std::string name; // Nombre del offset
|
|
||||||
textFile_t *textFile; // Los offsets de la fuente
|
|
||||||
};
|
|
||||||
|
|
||||||
struct res_tileMap_t
|
|
||||||
{
|
|
||||||
std::string name; // Nombre del mapa de tiles
|
|
||||||
std::vector<int> *tileMap; // Vector con los indices del mapa de tiles
|
|
||||||
};
|
|
||||||
|
|
||||||
struct res_room_t
|
|
||||||
{
|
|
||||||
std::string name; // Nombre de la habitación
|
|
||||||
room_t *room; // Vector con las habitaciones
|
|
||||||
};
|
|
||||||
|
|
||||||
// Clase Resource. Almacena recursos de disco en memoria
|
|
||||||
class Resource
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
// Objetos y punteros
|
|
||||||
SDL_Renderer *renderer; // El renderizador de la ventana
|
|
||||||
Asset *asset; // Objeto con la ruta a todos los ficheros de recursos
|
|
||||||
options_t *options; // Puntero a las opciones del juego
|
|
||||||
|
|
||||||
// Variables
|
|
||||||
std::vector<res_texture_t> textures;
|
|
||||||
std::vector<res_animation_t> animations;
|
|
||||||
std::vector<res_textOffset_t> offsets;
|
|
||||||
std::vector<res_tileMap_t> tileMaps;
|
|
||||||
std::vector<res_room_t> rooms;
|
|
||||||
|
|
||||||
public:
|
|
||||||
// Constructor
|
|
||||||
Resource(SDL_Renderer *renderer, Asset *asset, options_t *options);
|
|
||||||
|
|
||||||
// Carga las texturas de una lista
|
|
||||||
void loadTextures(std::vector<std::string> list);
|
|
||||||
|
|
||||||
// Vuelve a cargar las texturas
|
|
||||||
void reLoadTextures();
|
|
||||||
|
|
||||||
// Carga las animaciones desde una lista
|
|
||||||
void loadAnimations(std::vector<std::string> list);
|
|
||||||
|
|
||||||
// Vuelve a cargar las animaciones
|
|
||||||
void reLoadAnimations();
|
|
||||||
|
|
||||||
// Carga los offsets desde una lista
|
|
||||||
void loadOffsets(std::vector<std::string> list);
|
|
||||||
|
|
||||||
// Vuelve a cargar los offsets
|
|
||||||
void reLoadOffsets();
|
|
||||||
|
|
||||||
// Carga los mapas de tiles desde una lista
|
|
||||||
void loadTileMaps(std::vector<std::string> list);
|
|
||||||
|
|
||||||
// Vuelve a cargar los mapas de tiles
|
|
||||||
void reLoadTileMaps();
|
|
||||||
|
|
||||||
// Carga las habitaciones desde una lista
|
|
||||||
void loadRooms(std::vector<std::string> list);
|
|
||||||
|
|
||||||
// Vuelve a cargar las habitaciones
|
|
||||||
void reLoadRooms();
|
|
||||||
|
|
||||||
// Vuelve a cargar todos los recursos
|
|
||||||
void reLoad();
|
|
||||||
|
|
||||||
// Libera las texturas
|
|
||||||
void freeTextures();
|
|
||||||
|
|
||||||
// Libera las animaciones
|
|
||||||
void freeAnimations();
|
|
||||||
|
|
||||||
// Libera los offsets
|
|
||||||
void freeOffsets();
|
|
||||||
|
|
||||||
// Libera los mapas de tiles
|
|
||||||
void freeTileMaps();
|
|
||||||
|
|
||||||
// Libera las habitaciones
|
|
||||||
void freeRooms();
|
|
||||||
|
|
||||||
// Libera todos los recursos
|
|
||||||
void free();
|
|
||||||
|
|
||||||
// Obtiene una textura
|
|
||||||
Texture *getTexture(std::string name);
|
|
||||||
|
|
||||||
// Obtiene una animación
|
|
||||||
animatedSprite_t *getAnimation(std::string name);
|
|
||||||
|
|
||||||
// Obtiene un offset
|
|
||||||
textFile_t *getOffset(std::string name);
|
|
||||||
|
|
||||||
// Obtiene un mapa de tiles
|
|
||||||
std::vector<int> *getTileMap(std::string name);
|
|
||||||
|
|
||||||
// Obtiene una habitacion
|
|
||||||
room_t *getRoom(std::string name);
|
|
||||||
|
|
||||||
// Obtiene todas las habitaciones
|
|
||||||
std::vector<res_room_t> *getAllRooms();
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
#include "../const.h"
|
|
||||||
#include "asset.h"
|
#include "asset.h"
|
||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
#include "text.h"
|
#include "text.h"
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
#include "../const.h"
|
|
||||||
#include "menu.h"
|
#include "menu.h"
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Menu::Menu(SDL_Renderer *renderer, Resource *resource, Asset *asset, Input *input, std::string file)
|
//Menu::Menu(SDL_Renderer *renderer, Resource *resource, Asset *asset, Input *input, std::string file)
|
||||||
|
Menu::Menu(SDL_Renderer *renderer, Asset *asset, Input *input, std::string file)
|
||||||
{
|
{
|
||||||
// Copia punteros
|
// Copia punteros
|
||||||
this->renderer = renderer;
|
this->renderer = renderer;
|
||||||
@@ -154,7 +154,7 @@ bool Menu::load(std::string file_path)
|
|||||||
// Crea el objeto text tan pronto como se pueda. Necesario para añadir items
|
// Crea el objeto text tan pronto como se pueda. Necesario para añadir items
|
||||||
if (font_png != "" && font_txt != "" && !textAllocated)
|
if (font_png != "" && font_txt != "" && !textAllocated)
|
||||||
{
|
{
|
||||||
text = new Text(resource->getOffset(font_txt), resource->getTexture(font_png), renderer);
|
text = new Text(asset->get(font_txt), asset->get(font_png), renderer);
|
||||||
textAllocated = true;
|
textAllocated = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -977,6 +977,6 @@ void Menu::setText(std::string font_png, std::string font_txt)
|
|||||||
{
|
{
|
||||||
if (!text)
|
if (!text)
|
||||||
{
|
{
|
||||||
text = new Text(resource->getOffset(font_txt), resource->getTexture(font_png), renderer);
|
text = new Text(asset->get(font_txt), asset->get(font_png), renderer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4,13 +4,14 @@
|
|||||||
#include "asset.h"
|
#include "asset.h"
|
||||||
#include "input.h"
|
#include "input.h"
|
||||||
#include "jail_audio.h"
|
#include "jail_audio.h"
|
||||||
#include "resource.h"
|
//#include "resource.h"
|
||||||
#include "sprite.h"
|
#include "sprite.h"
|
||||||
#include "text.h"
|
#include "text.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
#ifndef MENU_H
|
#ifndef MENU_H
|
||||||
#define MENU_H
|
#define MENU_H
|
||||||
@@ -71,7 +72,7 @@ private:
|
|||||||
|
|
||||||
// Objetos y punteros
|
// Objetos y punteros
|
||||||
SDL_Renderer *renderer; // Puntero al renderizador de la ventana
|
SDL_Renderer *renderer; // Puntero al renderizador de la ventana
|
||||||
Resource *resource; // Objeto con los recursos
|
//Resource *resource; // Objeto con los recursos
|
||||||
Asset *asset; // Objeto para gestionar los ficheros de recursos
|
Asset *asset; // Objeto para gestionar los ficheros de recursos
|
||||||
Text *text; // Texto para poder escribir los items del menu
|
Text *text; // Texto para poder escribir los items del menu
|
||||||
Input *input; // Gestor de eventos de entrada de teclado o gamepad
|
Input *input; // Gestor de eventos de entrada de teclado o gamepad
|
||||||
@@ -142,7 +143,8 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
Menu(SDL_Renderer *renderer, Resource *resource, Asset *asset, Input *input, std::string file = "");
|
//Menu(SDL_Renderer *renderer, Resource *resource, Asset *asset, Input *input, std::string file = "");
|
||||||
|
Menu(SDL_Renderer *renderer, Asset *asset, Input *input, std::string file = "");
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~Menu();
|
~Menu();
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "../const.h"
|
|
||||||
#include "movingsprite.h"
|
#include "movingsprite.h"
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
@@ -4,7 +4,6 @@
|
|||||||
#include "asset.h"
|
#include "asset.h"
|
||||||
#include "notify.h"
|
#include "notify.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "../const.h"
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#ifndef SCREEN_H
|
#ifndef SCREEN_H
|
||||||
@@ -4,7 +4,7 @@
|
|||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
// Llena una estructuta textFile_t desde un fichero
|
// Llena una estructuta textFile_t desde un fichero
|
||||||
textFile_t LoadTextFile(std::string file, bool verbose)
|
textFile_t LoadTextFile(string file, bool verbose)
|
||||||
{
|
{
|
||||||
textFile_t tf;
|
textFile_t tf;
|
||||||
|
|
||||||
@@ -17,31 +17,31 @@ textFile_t LoadTextFile(std::string file, bool verbose)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Abre el fichero para leer los valores
|
// Abre el fichero para leer los valores
|
||||||
const std::string filename = file.substr(file.find_last_of("\\/") + 1).c_str();
|
const string filename = file.substr(file.find_last_of("\\/") + 1).c_str();
|
||||||
std::ifstream rfile(file);
|
ifstream rfile(file);
|
||||||
|
|
||||||
if (rfile.is_open() && rfile.good())
|
if (rfile.is_open() && rfile.good())
|
||||||
{
|
{
|
||||||
std::string buffer;
|
string buffer;
|
||||||
|
|
||||||
// Lee los dos primeros valores del fichero
|
// Lee los dos primeros valores del fichero
|
||||||
std::getline(rfile, buffer);
|
getline(rfile, buffer);
|
||||||
std::getline(rfile, buffer);
|
getline(rfile, buffer);
|
||||||
tf.boxWidth = std::stoi(buffer);
|
tf.boxWidth = stoi(buffer);
|
||||||
|
|
||||||
std::getline(rfile, buffer);
|
getline(rfile, buffer);
|
||||||
std::getline(rfile, buffer);
|
getline(rfile, buffer);
|
||||||
tf.boxHeight = std::stoi(buffer);
|
tf.boxHeight = stoi(buffer);
|
||||||
|
|
||||||
// lee el resto de datos del fichero
|
// lee el resto de datos del fichero
|
||||||
int index = 32;
|
int index = 32;
|
||||||
int line_read = 0;
|
int line_read = 0;
|
||||||
while (std::getline(rfile, buffer))
|
while (getline(rfile, buffer))
|
||||||
{
|
{
|
||||||
// Almacena solo las lineas impares
|
// Almacena solo las lineas impares
|
||||||
if (line_read % 2 == 1)
|
if (line_read % 2 == 1)
|
||||||
{
|
{
|
||||||
tf.offset[index++].w = std::stoi(buffer);
|
tf.offset[index++].w = stoi(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Limpia el buffer
|
// Limpia el buffer
|
||||||
@@ -52,7 +52,7 @@ textFile_t LoadTextFile(std::string file, bool verbose)
|
|||||||
// Cierra el fichero
|
// Cierra el fichero
|
||||||
if (verbose)
|
if (verbose)
|
||||||
{
|
{
|
||||||
std::cout << "Text loaded: " << filename.c_str() << std::endl;
|
cout << "Text loaded: " << filename.c_str() << endl;
|
||||||
}
|
}
|
||||||
rfile.close();
|
rfile.close();
|
||||||
}
|
}
|
||||||
@@ -62,7 +62,7 @@ textFile_t LoadTextFile(std::string file, bool verbose)
|
|||||||
{
|
{
|
||||||
if (verbose)
|
if (verbose)
|
||||||
{
|
{
|
||||||
std::cout << "Warning: Unable to open " << filename.c_str() << " file" << std::endl;
|
cout << "Warning: Unable to open " << filename.c_str() << " file" << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,7 +77,31 @@ textFile_t LoadTextFile(std::string file, bool verbose)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Text::Text(std::string textFile, Texture *texture, SDL_Renderer *renderer)
|
Text::Text(string textFile, string bitmapFile, SDL_Renderer *renderer)
|
||||||
|
{
|
||||||
|
// Carga los offsets desde el fichero
|
||||||
|
textFile_t tf = LoadTextFile(textFile);
|
||||||
|
|
||||||
|
// Inicializa variables desde la estructura
|
||||||
|
boxHeight = tf.boxHeight;
|
||||||
|
boxWidth = tf.boxWidth;
|
||||||
|
for (int i = 0; i < 128; ++i)
|
||||||
|
{
|
||||||
|
offset[i].x = tf.offset[i].x;
|
||||||
|
offset[i].y = tf.offset[i].y;
|
||||||
|
offset[i].w = tf.offset[i].w;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Crea los objetos
|
||||||
|
texture = new Texture(renderer, bitmapFile);
|
||||||
|
sprite = new Sprite({0, 0, boxWidth, boxHeight}, texture, renderer);
|
||||||
|
|
||||||
|
// Inicializa variables
|
||||||
|
fixedWidth = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Constructor
|
||||||
|
Text::Text(string textFile, Texture *texture, SDL_Renderer *renderer)
|
||||||
{
|
{
|
||||||
// Carga los offsets desde el fichero
|
// Carga los offsets desde el fichero
|
||||||
textFile_t tf = LoadTextFile(textFile);
|
textFile_t tf = LoadTextFile(textFile);
|
||||||
@@ -123,10 +147,14 @@ Text::Text(textFile_t *textFile, Texture *texture, SDL_Renderer *renderer)
|
|||||||
Text::~Text()
|
Text::~Text()
|
||||||
{
|
{
|
||||||
delete sprite;
|
delete sprite;
|
||||||
|
if (texture)
|
||||||
|
{
|
||||||
|
delete texture;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Escribe texto en pantalla
|
// Escribe texto en pantalla
|
||||||
void Text::write(int x, int y, std::string text, int kerning, int lenght)
|
void Text::write(int x, int y, string text, int kerning, int lenght)
|
||||||
{
|
{
|
||||||
int shift = 0;
|
int shift = 0;
|
||||||
|
|
||||||
@@ -145,7 +173,7 @@ void Text::write(int x, int y, std::string text, int kerning, int lenght)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Escribe el texto con colores
|
// Escribe el texto con colores
|
||||||
void Text::writeColored(int x, int y, std::string text, color_t color, int kerning, int lenght)
|
void Text::writeColored(int x, int y, string text, color_t color, int kerning, int lenght)
|
||||||
{
|
{
|
||||||
sprite->getTexture()->setColor(color.r, color.g, color.b);
|
sprite->getTexture()->setColor(color.r, color.g, color.b);
|
||||||
write(x, y, text, kerning, lenght);
|
write(x, y, text, kerning, lenght);
|
||||||
@@ -153,7 +181,7 @@ void Text::writeColored(int x, int y, std::string text, color_t color, int kerni
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Escribe el texto con sombra
|
// Escribe el texto con sombra
|
||||||
void Text::writeShadowed(int x, int y, std::string text, color_t color, Uint8 shadowDistance, int kerning, int lenght)
|
void Text::writeShadowed(int x, int y, string text, color_t color, Uint8 shadowDistance, int kerning, int lenght)
|
||||||
{
|
{
|
||||||
sprite->getTexture()->setColor(color.r, color.g, color.b);
|
sprite->getTexture()->setColor(color.r, color.g, color.b);
|
||||||
write(x + shadowDistance, y + shadowDistance, text, kerning, lenght);
|
write(x + shadowDistance, y + shadowDistance, text, kerning, lenght);
|
||||||
@@ -162,14 +190,14 @@ void Text::writeShadowed(int x, int y, std::string text, color_t color, Uint8 sh
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Escribe el texto centrado en un punto x
|
// Escribe el texto centrado en un punto x
|
||||||
void Text::writeCentered(int x, int y, std::string text, int kerning, int lenght)
|
void Text::writeCentered(int x, int y, string text, int kerning, int lenght)
|
||||||
{
|
{
|
||||||
x -= (Text::lenght(text, kerning) / 2);
|
x -= (Text::lenght(text, kerning) / 2);
|
||||||
write(x, y, text, kerning, lenght);
|
write(x, y, text, kerning, lenght);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Escribe texto con extras
|
// Escribe texto con extras
|
||||||
void Text::writeDX(Uint8 flags, int x, int y, std::string text, int kerning, color_t textColor, Uint8 shadowDistance, color_t shadowColor, int lenght)
|
void Text::writeDX(Uint8 flags, int x, int y, string text, int kerning, color_t textColor, Uint8 shadowDistance, color_t shadowColor, int lenght)
|
||||||
{
|
{
|
||||||
const bool centered = ((flags & TXT_CENTER) == TXT_CENTER);
|
const bool centered = ((flags & TXT_CENTER) == TXT_CENTER);
|
||||||
const bool shadowed = ((flags & TXT_SHADOW) == TXT_SHADOW);
|
const bool shadowed = ((flags & TXT_SHADOW) == TXT_SHADOW);
|
||||||
@@ -211,7 +239,7 @@ void Text::writeDX(Uint8 flags, int x, int y, std::string text, int kerning, col
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Obtiene la longitud en pixels de una cadena
|
// Obtiene la longitud en pixels de una cadena
|
||||||
int Text::lenght(std::string text, int kerning)
|
int Text::lenght(string text, int kerning)
|
||||||
{
|
{
|
||||||
int shift = 0;
|
int shift = 0;
|
||||||
|
|
||||||
@@ -26,14 +26,15 @@ struct textFile_t
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Llena una estructuta textFile_t desde un fichero
|
// Llena una estructuta textFile_t desde un fichero
|
||||||
textFile_t LoadTextFile(std::string file, bool verbose = false);
|
textFile_t LoadTextFile(string file, bool verbose = false);
|
||||||
|
|
||||||
// Clase texto. Pinta texto en pantalla a partir de un bitmap
|
// Clase texto. Pinta texto en pantalla a partir de un bitmap
|
||||||
class Text
|
class Text
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
// Objetos y punteros
|
// Objetos y punteros
|
||||||
Sprite *sprite; // Objeto con los graficos para el texto
|
Texture *texture; // Textura con los gráficos para el texto
|
||||||
|
Sprite *sprite; // Objeto para dibujar el texto
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
int boxWidth; // Anchura de la caja de cada caracter en el png
|
int boxWidth; // Anchura de la caja de cada caracter en el png
|
||||||
@@ -43,29 +44,30 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
Text(std::string textFile, Texture *texture, SDL_Renderer *renderer);
|
Text(string textFile, string bitmapFile, SDL_Renderer *renderer);
|
||||||
|
Text(string textFile, Texture *texture, SDL_Renderer *renderer);
|
||||||
Text(textFile_t *textFile, Texture *texture, SDL_Renderer *renderer);
|
Text(textFile_t *textFile, Texture *texture, SDL_Renderer *renderer);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~Text();
|
~Text();
|
||||||
|
|
||||||
// Escribe el texto en pantalla
|
// Escribe el texto en pantalla
|
||||||
void write(int x, int y, std::string text, int kerning = 1, int lenght = -1);
|
void write(int x, int y, string text, int kerning = 1, int lenght = -1);
|
||||||
|
|
||||||
// Escribe el texto con colores
|
// Escribe el texto con colores
|
||||||
void writeColored(int x, int y, std::string text, color_t color, int kerning = 1, int lenght = -1);
|
void writeColored(int x, int y, string text, color_t color, int kerning = 1, int lenght = -1);
|
||||||
|
|
||||||
// Escribe el texto con sombra
|
// Escribe el texto con sombra
|
||||||
void writeShadowed(int x, int y, std::string text, color_t color, Uint8 shadowDistance = 1, int kerning = 1, int lenght = -1);
|
void writeShadowed(int x, int y, string text, color_t color, Uint8 shadowDistance = 1, int kerning = 1, int lenght = -1);
|
||||||
|
|
||||||
// Escribe el texto centrado en un punto x
|
// Escribe el texto centrado en un punto x
|
||||||
void writeCentered(int x, int y, std::string text, int kerning = 1, int lenght = -1);
|
void writeCentered(int x, int y, string text, int kerning = 1, int lenght = -1);
|
||||||
|
|
||||||
// Escribe texto con extras
|
// Escribe texto con extras
|
||||||
void writeDX(Uint8 flags, int x, int y, std::string text, int kerning = 1, color_t textColor = {255, 255, 255}, Uint8 shadowDistance = 1, color_t shadowColor = {0, 0, 0}, int lenght = -1);
|
void writeDX(Uint8 flags, int x, int y, string text, int kerning = 1, color_t textColor = {255, 255, 255}, Uint8 shadowDistance = 1, color_t shadowColor = {0, 0, 0}, int lenght = -1);
|
||||||
|
|
||||||
// Obtiene la longitud en pixels de una cadena
|
// Obtiene la longitud en pixels de una cadena
|
||||||
int lenght(std::string text, int kerning = 1);
|
int lenght(string text, int kerning = 1);
|
||||||
|
|
||||||
// Devuelve el valor de la variable
|
// Devuelve el valor de la variable
|
||||||
int getCharacterSize();
|
int getCharacterSize();
|
||||||
@@ -348,7 +348,7 @@ bool checkCollision(SDL_Point &p, d_line_t &l)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Devuelve un color_t a partir de un string
|
// Devuelve un color_t a partir de un string
|
||||||
color_t stringToColor(palette_e pal, std::string str)
|
color_t stringToColor(palette_e pal, string str)
|
||||||
{
|
{
|
||||||
if (pal == p_zxspectrum)
|
if (pal == p_zxspectrum)
|
||||||
{
|
{
|
||||||
@@ -520,7 +520,7 @@ color_t stringToColor(palette_e pal, std::string str)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Convierte una cadena en un valor booleano
|
// Convierte una cadena en un valor booleano
|
||||||
bool stringToBool(std::string str)
|
bool stringToBool(string str)
|
||||||
{
|
{
|
||||||
if (str == "true")
|
if (str == "true")
|
||||||
{
|
{
|
||||||
@@ -533,7 +533,7 @@ bool stringToBool(std::string str)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Convierte un valor booleano en una cadena
|
// Convierte un valor booleano en una cadena
|
||||||
std::string boolToString(bool value)
|
string boolToString(bool value)
|
||||||
{
|
{
|
||||||
if (value)
|
if (value)
|
||||||
{
|
{
|
||||||
@@ -7,6 +7,8 @@
|
|||||||
#ifndef UTILS_H
|
#ifndef UTILS_H
|
||||||
#define UTILS_H
|
#define UTILS_H
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
// Estructura para definir un circulo
|
// Estructura para definir un circulo
|
||||||
struct circle_t
|
struct circle_t
|
||||||
{
|
{
|
||||||
@@ -102,10 +104,10 @@ struct online_t
|
|||||||
{
|
{
|
||||||
bool enabled; // Indica si se quiere usar el modo online o no
|
bool enabled; // Indica si se quiere usar el modo online o no
|
||||||
bool sessionEnabled; // Indica ya se ha hecho login
|
bool sessionEnabled; // Indica ya se ha hecho login
|
||||||
std::string server; // Servidor para los servicios online
|
string server; // Servidor para los servicios online
|
||||||
int port; // Puerto del servidor
|
int port; // Puerto del servidor
|
||||||
std::string gameID; // Identificador del juego para los servicios online
|
string gameID; // Identificador del juego para los servicios online
|
||||||
std::string jailerID; // Identificador del jugador para los servicios online
|
string jailerID; // Identificador del jugador para los servicios online
|
||||||
int score; // Puntuación almacenada online
|
int score; // Puntuación almacenada online
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -114,7 +116,7 @@ struct op_stats_t
|
|||||||
{
|
{
|
||||||
int rooms; // Cantidad de habitaciones visitadas
|
int rooms; // Cantidad de habitaciones visitadas
|
||||||
int items; // Cantidad de items obtenidos
|
int items; // Cantidad de items obtenidos
|
||||||
std::string worstNightmare; // Habitación con más muertes acumuladas
|
string worstNightmare; // Habitación con más muertes acumuladas
|
||||||
};
|
};
|
||||||
|
|
||||||
// Estructura con opciones de la pantalla
|
// Estructura con opciones de la pantalla
|
||||||
@@ -127,7 +129,7 @@ struct op_screen_t
|
|||||||
// Estructura con todas las opciones de configuración del programa
|
// Estructura con todas las opciones de configuración del programa
|
||||||
struct options_t
|
struct options_t
|
||||||
{
|
{
|
||||||
std::string configVersion; // Versión del programa. Sirve para saber si las opciones son compatibles
|
string configVersion; // Versión del programa. Sirve para saber si las opciones son compatibles
|
||||||
Uint32 videoMode; // Contiene el valor del modo de pantalla completa
|
Uint32 videoMode; // Contiene el valor del modo de pantalla completa
|
||||||
int windowSize; // Contiene el valor por el que se multiplica el tamaño de la ventana
|
int windowSize; // Contiene el valor por el que se multiplica el tamaño de la ventana
|
||||||
Uint32 filter; // Filtro usado para el escalado de la imagen
|
Uint32 filter; // Filtro usado para el escalado de la imagen
|
||||||
@@ -186,13 +188,13 @@ bool checkCollision(SDL_Point &p, d_line_t &l);
|
|||||||
void normalizeLine(d_line_t &l);
|
void normalizeLine(d_line_t &l);
|
||||||
|
|
||||||
// Devuelve un color_t a partir de un string
|
// Devuelve un color_t a partir de un string
|
||||||
color_t stringToColor(palette_e pal, std::string str);
|
color_t stringToColor(palette_e pal, string str);
|
||||||
|
|
||||||
// Convierte una cadena en un valor booleano
|
// Convierte una cadena en un valor booleano
|
||||||
bool stringToBool(std::string str);
|
bool stringToBool(string str);
|
||||||
|
|
||||||
// Convierte un valor booleano en una cadena
|
// Convierte un valor booleano en una cadena
|
||||||
std::string boolToString(bool value);
|
string boolToString(bool value);
|
||||||
|
|
||||||
// Compara dos colores
|
// Compara dos colores
|
||||||
bool colorAreEqual(color_t color1, color_t color2);
|
bool colorAreEqual(color_t color1, color_t color2);
|
||||||
Reference in New Issue
Block a user