forked from jaildesigner-jailgames/jaildoctors_dilemma
Precarga de los ficheros .txt con los offsets del texto
This commit is contained in:
@@ -1,16 +1,16 @@
|
|||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Debug::Debug(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset)
|
Debug::Debug(SDL_Renderer *renderer, Screen *screen, Asset *asset)
|
||||||
{
|
{
|
||||||
// Copia la dirección de los objetos
|
// Copia la dirección de los objetos
|
||||||
this->resource = resource;
|
|
||||||
this->renderer = renderer;
|
this->renderer = renderer;
|
||||||
this->screen = screen;
|
this->screen = screen;
|
||||||
this->asset = asset;
|
this->asset = asset;
|
||||||
|
|
||||||
// Reserva memoria para los punteros
|
// Reserva memoria para los punteros
|
||||||
text = new Text("debug.png", asset->get("debug.txt"), resource, renderer);
|
texture = new Texture(renderer, asset->get("debug.png"));
|
||||||
|
text = new Text(asset->get("debug.txt"), texture, renderer);
|
||||||
|
|
||||||
// Inicializa variables
|
// Inicializa variables
|
||||||
x = 0;
|
x = 0;
|
||||||
@@ -21,6 +21,7 @@ Debug::Debug(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *
|
|||||||
// Destructor
|
// Destructor
|
||||||
Debug::~Debug()
|
Debug::~Debug()
|
||||||
{
|
{
|
||||||
|
delete texture;
|
||||||
delete text;
|
delete text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
#include "asset.h"
|
#include "asset.h"
|
||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
#include "text.h"
|
#include "text.h"
|
||||||
|
#include "texture.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@@ -19,9 +20,9 @@ private:
|
|||||||
// Objetos y punteros
|
// Objetos y punteros
|
||||||
SDL_Renderer *renderer; // El renderizador de la ventana
|
SDL_Renderer *renderer; // El renderizador de la ventana
|
||||||
Screen *screen; // Objeto encargado de dibujar en pantalla
|
Screen *screen; // Objeto encargado de dibujar en pantalla
|
||||||
Resource *resource; // Objeto con los recursos
|
|
||||||
Asset *asset; // Objeto con los ficheros de recursos
|
Asset *asset; // Objeto con los ficheros de recursos
|
||||||
Text *text; // Objeto encargado de escribir texto en pantalla
|
Text *text; // Objeto encargado de escribir texto en pantalla
|
||||||
|
Texture *texture; // Textura para el texto
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
std::vector<std::string> slot; // Vector con los textos a escribir
|
std::vector<std::string> slot; // Vector con los textos a escribir
|
||||||
@@ -32,7 +33,7 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
Debug(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset);
|
Debug(SDL_Renderer *renderer, Screen *screen, Asset *asset);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~Debug();
|
~Debug();
|
||||||
|
|||||||
@@ -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(font_png, asset->get(font_txt), resource, renderer);
|
text = new Text(resource->getOffset(font_txt), resource->getTexture(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(font_png, font_txt, resource, renderer);
|
text = new Text(resource->getOffset(font_txt), resource->getTexture(font_png), renderer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -16,7 +16,7 @@ void Resource::loadTextures(std::vector<std::string> list)
|
|||||||
{
|
{
|
||||||
texture_t t;
|
texture_t t;
|
||||||
t.name = l;
|
t.name = l;
|
||||||
t.texture = new Texture(renderer, asset->get(t.name));
|
t.texture = new Texture(renderer, asset->get(l));
|
||||||
textures.push_back(t);
|
textures.push_back(t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -33,6 +33,18 @@ void Resource::loadAnimations(std::vector<std::string> list)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Carga los offsets desde una lista
|
||||||
|
void Resource::loadOffsets(std::vector<std::string> list)
|
||||||
|
{
|
||||||
|
for (auto l : list)
|
||||||
|
{
|
||||||
|
textOffset_t to;
|
||||||
|
to.name = l;
|
||||||
|
to.textFile = new textFile_t(LoadTextFile(asset->get(l)));
|
||||||
|
offsets.push_back(to);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Recarga las texturas
|
// Recarga las texturas
|
||||||
void Resource::reLoadTextures()
|
void Resource::reLoadTextures()
|
||||||
{
|
{
|
||||||
@@ -62,11 +74,22 @@ void Resource::freeAnimations()
|
|||||||
animations.clear();
|
animations.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Libera los offsets
|
||||||
|
void Resource::freeOffsets()
|
||||||
|
{
|
||||||
|
for (auto o : offsets)
|
||||||
|
{
|
||||||
|
delete o.textFile;
|
||||||
|
}
|
||||||
|
offsets.clear();
|
||||||
|
}
|
||||||
|
|
||||||
// Libera todos los recursos
|
// Libera todos los recursos
|
||||||
void Resource::free()
|
void Resource::free()
|
||||||
{
|
{
|
||||||
freeTextures();
|
freeTextures();
|
||||||
freeAnimations();
|
freeAnimations();
|
||||||
|
freeOffsets();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Obtiene una textura
|
// Obtiene una textura
|
||||||
@@ -100,3 +123,19 @@ animatedSprite_t *Resource::getAnimation(std::string name)
|
|||||||
std::cout << "NOT FOUND: " << name << std::endl;
|
std::cout << "NOT FOUND: " << name << std::endl;
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Obtiene un offset
|
||||||
|
textFile_t *Resource::getOffset(std::string name)
|
||||||
|
{
|
||||||
|
for (auto offset : offsets)
|
||||||
|
{
|
||||||
|
if (offset.name.find(name) != std::string::npos)
|
||||||
|
{
|
||||||
|
std::cout << "CACHE: " << name << std::endl;
|
||||||
|
return offset.textFile;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::cout << "NOT FOUND: " << name << std::endl;
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
@@ -3,6 +3,7 @@
|
|||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
#include "animatedsprite.h"
|
#include "animatedsprite.h"
|
||||||
#include "asset.h"
|
#include "asset.h"
|
||||||
|
#include "text.h"
|
||||||
#include "texture.h"
|
#include "texture.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
@@ -19,10 +20,17 @@ struct texture_t
|
|||||||
|
|
||||||
struct animation_t
|
struct animation_t
|
||||||
{
|
{
|
||||||
std::string name; // Nombre de la textura
|
std::string name; // Nombre de la textura
|
||||||
animatedSprite_t *animation; // La animación
|
animatedSprite_t *animation; // La animación
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct textOffset_t
|
||||||
|
{
|
||||||
|
std::string name; // Nombre del offeset
|
||||||
|
textFile_t *textFile; // Los offsets de la fuente
|
||||||
|
};
|
||||||
|
|
||||||
|
// Clase Resource. Almacena recursos de disco en memoria
|
||||||
class Resource
|
class Resource
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
@@ -34,6 +42,7 @@ private:
|
|||||||
// Variables
|
// Variables
|
||||||
std::vector<texture_t> textures;
|
std::vector<texture_t> textures;
|
||||||
std::vector<animation_t> animations;
|
std::vector<animation_t> animations;
|
||||||
|
std::vector<textOffset_t> offsets;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
@@ -45,6 +54,9 @@ public:
|
|||||||
// Carga las animaciones desde una lista
|
// Carga las animaciones desde una lista
|
||||||
void loadAnimations(std::vector<std::string> list);
|
void loadAnimations(std::vector<std::string> list);
|
||||||
|
|
||||||
|
// Carga los offsets desde una lista
|
||||||
|
void loadOffsets(std::vector<std::string> list);
|
||||||
|
|
||||||
// Recarga las texturas
|
// Recarga las texturas
|
||||||
void reLoadTextures();
|
void reLoadTextures();
|
||||||
|
|
||||||
@@ -54,6 +66,9 @@ public:
|
|||||||
// Libera las animaciones
|
// Libera las animaciones
|
||||||
void freeAnimations();
|
void freeAnimations();
|
||||||
|
|
||||||
|
// Libera los offsets
|
||||||
|
void freeOffsets();
|
||||||
|
|
||||||
// Libera todos los recursos
|
// Libera todos los recursos
|
||||||
void free();
|
void free();
|
||||||
|
|
||||||
@@ -62,6 +77,9 @@ public:
|
|||||||
|
|
||||||
// Obtiene una animación
|
// Obtiene una animación
|
||||||
animatedSprite_t *getAnimation(std::string name);
|
animatedSprite_t *getAnimation(std::string name);
|
||||||
|
|
||||||
|
// Obtiene un offset
|
||||||
|
textFile_t *getOffset(std::string name);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -3,17 +3,97 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
// Constructor
|
// Llena una estructuta textFile_t desde un fichero
|
||||||
Text::Text(std::string bitmapFile, std::string textFile, Resource *resource, SDL_Renderer *renderer)
|
textFile_t LoadTextFile(std::string file)
|
||||||
{
|
{
|
||||||
// Copia punteros
|
textFile_t tf;
|
||||||
this->resource = resource;
|
|
||||||
|
|
||||||
|
// Inicializa a cero el vector con las coordenadas
|
||||||
|
for (int i = 0; i < 128; ++i)
|
||||||
|
{
|
||||||
|
tf.offset[i].x = 0;
|
||||||
|
tf.offset[i].y = 0;
|
||||||
|
tf.offset[i].w = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Abre el fichero para leer los valores
|
||||||
|
const std::string filename = file.substr(file.find_last_of("\\/") + 1).c_str();
|
||||||
|
std::ifstream rfile(file);
|
||||||
|
|
||||||
|
if (rfile.is_open() && rfile.good())
|
||||||
|
{
|
||||||
|
std::string buffer;
|
||||||
|
|
||||||
|
// Lee los dos primeros valores del fichero
|
||||||
|
std::getline(rfile, buffer);
|
||||||
|
std::getline(rfile, buffer);
|
||||||
|
tf.boxWidth = std::stoi(buffer);
|
||||||
|
|
||||||
|
std::getline(rfile, buffer);
|
||||||
|
std::getline(rfile, buffer);
|
||||||
|
tf.boxHeight = std::stoi(buffer);
|
||||||
|
|
||||||
|
// lee el resto de datos del fichero
|
||||||
|
int index = 32;
|
||||||
|
int line_read = 0;
|
||||||
|
while (std::getline(rfile, buffer))
|
||||||
|
{
|
||||||
|
// Almacena solo las lineas impares
|
||||||
|
if (line_read % 2 == 1)
|
||||||
|
{
|
||||||
|
tf.offset[index++].w = std::stoi(buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Limpia el buffer
|
||||||
|
buffer.clear();
|
||||||
|
line_read++;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Cierra el fichero
|
||||||
|
printf("Text loaded: %s\n", filename.c_str());
|
||||||
|
rfile.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
// El fichero no se puede abrir
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printf("Warning: Unable to open %s file\n", filename.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Establece las coordenadas para cada caracter ascii de la cadena y su ancho
|
||||||
|
for (int i = 32; i < 128; ++i)
|
||||||
|
{
|
||||||
|
tf.offset[i].x = ((i - 32) % 15) * tf.boxWidth;
|
||||||
|
tf.offset[i].y = ((i - 32) / 15) * tf.boxHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
return tf;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Constructor
|
||||||
|
Text::Text(std::string textFile, Texture *texture, SDL_Renderer *renderer)
|
||||||
|
{
|
||||||
// Carga los offsets desde el fichero
|
// Carga los offsets desde el fichero
|
||||||
initOffsetFromFile(textFile);
|
initOffsetFromFile(textFile);
|
||||||
|
|
||||||
// Crea los objetos
|
// Crea los objetos
|
||||||
texture = resource->getTexture(bitmapFile);
|
sprite = new Sprite({0, 0, boxWidth, boxHeight}, texture, renderer);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Constructor
|
||||||
|
Text::Text(textFile_t *textFile, Texture *texture, SDL_Renderer *renderer)
|
||||||
|
{
|
||||||
|
// Inicializa variables desde la estructura
|
||||||
|
boxHeight = textFile->boxHeight;
|
||||||
|
boxWidth = textFile->boxWidth;
|
||||||
|
for (int i = 0; i < 128; ++i)
|
||||||
|
{
|
||||||
|
offset[i].x = textFile->offset[i].x;
|
||||||
|
offset[i].y = textFile->offset[i].y;
|
||||||
|
offset[i].w = textFile->offset[i].w;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Crea los objetos
|
||||||
sprite = new Sprite({0, 0, boxWidth, boxHeight}, texture, renderer);
|
sprite = new Sprite({0, 0, boxWidth, boxHeight}, texture, renderer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -190,5 +270,5 @@ int Text::getCharacterSize()
|
|||||||
// Recarga la textura
|
// Recarga la textura
|
||||||
void Text::reLoadTexture()
|
void Text::reLoadTexture()
|
||||||
{
|
{
|
||||||
texture->reLoad();
|
sprite->getTexture()->reLoad();
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "sprite.h"
|
#include "sprite.h"
|
||||||
#include "resource.h"
|
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
#ifndef TEXT_H
|
#ifndef TEXT_H
|
||||||
@@ -12,21 +11,29 @@
|
|||||||
#define TXT_CENTER 4
|
#define TXT_CENTER 4
|
||||||
#define TXT_STROKE 8
|
#define TXT_STROKE 8
|
||||||
|
|
||||||
|
struct offset_t
|
||||||
|
{
|
||||||
|
int x;
|
||||||
|
int y;
|
||||||
|
int w;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct textFile_t
|
||||||
|
{
|
||||||
|
int boxWidth; // Anchura de la caja de cada caracter en el png
|
||||||
|
int boxHeight; // Altura de la caja de cada caracter en el png
|
||||||
|
offset_t offset[128]; // Vector con las posiciones y ancho de cada letra
|
||||||
|
};
|
||||||
|
|
||||||
|
// Llena una estructuta textFile_t desde un fichero
|
||||||
|
textFile_t LoadTextFile(std::string file);
|
||||||
|
|
||||||
// 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:
|
||||||
struct offset_t
|
|
||||||
{
|
|
||||||
int x;
|
|
||||||
int y;
|
|
||||||
int w;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Objetos y punteros
|
// Objetos y punteros
|
||||||
Resource *resource; // Objeto con los recursos
|
|
||||||
Sprite *sprite; // Objeto con los graficos para el texto
|
Sprite *sprite; // Objeto con los graficos para el texto
|
||||||
Texture *texture; // Textura con los bitmaps del 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
|
||||||
@@ -38,7 +45,8 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
Text(std::string bitmapFile, std::string textFile, Resource *resource, SDL_Renderer *renderer);
|
Text(std::string textFile, Texture *texture, SDL_Renderer *renderer);
|
||||||
|
Text(textFile_t *textFile, Texture *texture, SDL_Renderer *renderer);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~Text();
|
~Text();
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ Credits::Credits(SDL_Renderer *renderer, Screen *screen, Resource *resource, Ass
|
|||||||
|
|
||||||
// Reserva memoria para los punteros
|
// Reserva memoria para los punteros
|
||||||
eventHandler = new SDL_Event();
|
eventHandler = new SDL_Event();
|
||||||
text = new Text("smb2.png", asset->get("smb2.txt"), resource, renderer);
|
text = new Text(resource->getOffset("smb2.txt"), resource->getTexture("smb2.png"), renderer);
|
||||||
texture = resource->getTexture("shine.png");
|
texture = resource->getTexture("shine.png");
|
||||||
sprite = new AnimatedSprite(renderer, resource->getAnimation("shine.ani"));
|
sprite = new AnimatedSprite(renderer, resource->getAnimation("shine.ani"));
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ Demo::Demo(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *as
|
|||||||
scoreboard = new ScoreBoard(renderer, resource, asset, options, &board);
|
scoreboard = new ScoreBoard(renderer, resource, asset, options, &board);
|
||||||
room = new Room(asset->get(currentRoom), renderer, screen, resource, asset, options, itemTracker, &board.items, debug);
|
room = new Room(asset->get(currentRoom), renderer, screen, resource, asset, options, itemTracker, &board.items, debug);
|
||||||
eventHandler = new SDL_Event();
|
eventHandler = new SDL_Event();
|
||||||
text = new Text("smb2.png", asset->get("smb2.txt"), resource, renderer);
|
text = new Text(resource->getOffset("smb2.txt"), resource->getTexture("smb2.png"), renderer);
|
||||||
|
|
||||||
// Inicializa el resto de variables
|
// Inicializa el resto de variables
|
||||||
counter = 0;
|
counter = 0;
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ Director::Director(std::string path)
|
|||||||
screen = new Screen(window, renderer, options, GAMECANVAS_WIDTH, GAMECANVAS_HEIGHT);
|
screen = new Screen(window, renderer, options, GAMECANVAS_WIDTH, GAMECANVAS_HEIGHT);
|
||||||
screen->setBorderColor(borderColor);
|
screen->setBorderColor(borderColor);
|
||||||
screen->setVideoMode(options->fullScreenMode);
|
screen->setVideoMode(options->fullScreenMode);
|
||||||
debug = new Debug(renderer, screen, resource, asset);
|
debug = new Debug(renderer, screen, asset);
|
||||||
music = JA_LoadMusic(asset->get("title.ogg").c_str());
|
music = JA_LoadMusic(asset->get("title.ogg").c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -181,7 +181,7 @@ bool Director::saveConfig()
|
|||||||
// Carga los recursos
|
// Carga los recursos
|
||||||
void Director::loadResources(section_t section)
|
void Director::loadResources(section_t section)
|
||||||
{
|
{
|
||||||
std::cout << "** LOAD RESOURCES" << std::endl;
|
std::cout << "** LOAD RESOURCES" << std::endl;
|
||||||
|
|
||||||
if (section.name == SECTION_PROG_LOGO)
|
if (section.name == SECTION_PROG_LOGO)
|
||||||
{
|
{
|
||||||
@@ -211,6 +211,12 @@ void Director::loadResources(section_t section)
|
|||||||
textureList.push_back("smb2.png");
|
textureList.push_back("smb2.png");
|
||||||
|
|
||||||
resource->loadTextures(textureList);
|
resource->loadTextures(textureList);
|
||||||
|
|
||||||
|
// Offsets
|
||||||
|
std::vector<std::string> offsetsList;
|
||||||
|
offsetsList.push_back("smb2.txt");
|
||||||
|
|
||||||
|
resource->loadOffsets(offsetsList);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (section.name == SECTION_PROG_CREDITS)
|
else if (section.name == SECTION_PROG_CREDITS)
|
||||||
@@ -222,10 +228,17 @@ void Director::loadResources(section_t section)
|
|||||||
|
|
||||||
resource->loadTextures(textureList);
|
resource->loadTextures(textureList);
|
||||||
|
|
||||||
|
// Animaciones
|
||||||
std::vector<std::string> animationList;
|
std::vector<std::string> animationList;
|
||||||
animationList.push_back("shine");
|
animationList.push_back("shine");
|
||||||
|
|
||||||
resource->loadAnimations(animationList);
|
resource->loadAnimations(animationList);
|
||||||
|
|
||||||
|
// Offsets
|
||||||
|
std::vector<std::string> offsetsList;
|
||||||
|
offsetsList.push_back("smb2.txt");
|
||||||
|
|
||||||
|
resource->loadOffsets(offsetsList);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (section.name == SECTION_PROG_GAME || section.name == SECTION_PROG_DEMO)
|
else if (section.name == SECTION_PROG_GAME || section.name == SECTION_PROG_DEMO)
|
||||||
@@ -340,9 +353,16 @@ void Director::loadResources(section_t section)
|
|||||||
animationList.push_back("bat");
|
animationList.push_back("bat");
|
||||||
|
|
||||||
resource->loadAnimations(animationList);
|
resource->loadAnimations(animationList);
|
||||||
|
|
||||||
|
// Offsets
|
||||||
|
std::vector<std::string> offsetsList;
|
||||||
|
offsetsList.push_back("smb2.txt");
|
||||||
|
offsetsList.push_back("debug.txt");
|
||||||
|
|
||||||
|
resource->loadOffsets(offsetsList);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << "** RESOURCES LOADED" << std::endl;
|
std::cout << "** RESOURCES LOADED" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Asigna variables a partir de dos cadenas
|
// Asigna variables a partir de dos cadenas
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ Game::Game(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *as
|
|||||||
room = new Room(asset->get(currentRoom), renderer, screen, resource, asset, options, itemTracker, &board.items, debug);
|
room = new Room(asset->get(currentRoom), renderer, screen, resource, asset, options, itemTracker, &board.items, debug);
|
||||||
player = new Player(spawnPoint, "player.png", "player.ani", renderer, resource, asset, options, input, room, debug);
|
player = new Player(spawnPoint, "player.png", "player.ani", renderer, resource, asset, options, input, room, debug);
|
||||||
eventHandler = new SDL_Event();
|
eventHandler = new SDL_Event();
|
||||||
text = new Text("smb2.png", asset->get("smb2.txt"), resource, renderer);
|
text = new Text(resource->getOffset("smb2.txt"), resource->getTexture("smb2.png"), renderer);
|
||||||
music = JA_LoadMusic(asset->get("game.ogg").c_str());
|
music = JA_LoadMusic(asset->get("game.ogg").c_str());
|
||||||
deathSound = JA_LoadSound(asset->get("death.wav").c_str());
|
deathSound = JA_LoadSound(asset->get("death.wav").c_str());
|
||||||
test = new Test(renderer, screen, asset, debug);
|
test = new Test(renderer, screen, asset, debug);
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ ScoreBoard::ScoreBoard(SDL_Renderer *renderer, Resource *resource, Asset *asset,
|
|||||||
itemTexture = resource->getTexture("items.png");
|
itemTexture = resource->getTexture("items.png");
|
||||||
sprite = new AnimatedSprite(renderer, resource->getAnimation("player.ani"));
|
sprite = new AnimatedSprite(renderer, resource->getAnimation("player.ani"));
|
||||||
sprite->setCurrentAnimation("walk_menu");
|
sprite->setCurrentAnimation("walk_menu");
|
||||||
text = new Text("smb2.png", asset->get("smb2.txt"), resource, renderer);
|
text = new Text(resource->getOffset("smb2.txt"), resource->getTexture("smb2.png"), renderer);
|
||||||
|
|
||||||
// Inicializa las variables
|
// Inicializa las variables
|
||||||
counter = 0;
|
counter = 0;
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ Title::Title(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *
|
|||||||
texture = resource->getTexture("loading_screen_color_zxarne.png");
|
texture = resource->getTexture("loading_screen_color_zxarne.png");
|
||||||
}
|
}
|
||||||
sprite = new Sprite(0, 0, texture->getWidth(), texture->getHeight(), texture, renderer);
|
sprite = new Sprite(0, 0, texture->getWidth(), texture->getHeight(), texture, renderer);
|
||||||
text = new Text("smb2.png", asset->get("smb2.txt"), resource, renderer);
|
text = new Text(resource->getOffset("smb2.txt"), resource->getTexture("smb2.png"), renderer);
|
||||||
|
|
||||||
// Inicializa variables
|
// Inicializa variables
|
||||||
counter = 0;
|
counter = 0;
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ private:
|
|||||||
// Objetos y punteros
|
// Objetos y punteros
|
||||||
SDL_Renderer *renderer; // El renderizador de la ventana
|
SDL_Renderer *renderer; // El renderizador de la ventana
|
||||||
Screen *screen; // Objeto encargado de dibujar en pantalla
|
Screen *screen; // Objeto encargado de dibujar en pantalla
|
||||||
Resource *resource; // Objeto con los recursos
|
Resource *resource; // Objeto con los recursos
|
||||||
Asset *asset; // Objeto con los ficheros de recursos
|
Asset *asset; // Objeto con los ficheros de recursos
|
||||||
SDL_Event *eventHandler; // Manejador de eventos
|
SDL_Event *eventHandler; // Manejador de eventos
|
||||||
Texture *texture; // Textura con los graficos
|
Texture *texture; // Textura con los graficos
|
||||||
|
|||||||
Reference in New Issue
Block a user