Segmentation fault
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -9,3 +9,4 @@ thumbs.db
|
||||
*.zip
|
||||
*.app
|
||||
*_debug*
|
||||
jail_engine*
|
||||
15
Makefile
Normal file
15
Makefile
Normal file
@@ -0,0 +1,15 @@
|
||||
executable = jail_engine_demo
|
||||
source = *.cpp units/*.cpp
|
||||
|
||||
windows:
|
||||
@echo off
|
||||
g++ $(source) -std=c++11 -Wall -Os -lmingw32 -lws2_32 -lSDL2main -lSDL2 -ffunction-sections -fdata-sections -Wl,--gc-sections -static-libstdc++ -Wl,-subsystem,windows -o "$(executable).exe"
|
||||
strip -s -R .comment -R .gnu.version "$(executable).exe" --strip-unneeded
|
||||
|
||||
macos:
|
||||
clang++ $(source) -std=c++11 -Wall -Os -lSDL2 -ffunction-sections -fdata-sections -o "$(executable)"
|
||||
|
||||
|
||||
linux:
|
||||
g++ $(source) -std=c++11 -Wall -Os -lSDL2 -ffunction-sections -fdata-sections -Wl,--gc-sections -o "$(executable)"
|
||||
strip -s -R .comment -R .gnu.version "$(executable)" --strip-unneeded
|
||||
42
main.cpp
42
main.cpp
@@ -18,8 +18,8 @@ Código fuente creado por JailDesigner
|
||||
SDL_Event *event;
|
||||
SDL_Window *window;
|
||||
SDL_Renderer *renderer;
|
||||
int ticks = 0;
|
||||
int ticksSpeed = 15;
|
||||
Uint32 ticks = 0;
|
||||
Uint32 ticksSpeed = 15;
|
||||
int counter = 0;
|
||||
int gradColorMin = 64; // Minimo color más alto del degradado
|
||||
int gradColorMax = 192; // Minimo color más alto del degradado
|
||||
@@ -28,7 +28,6 @@ int gradBreathDirection = 0; // Indica si gradCurrentColor crece o decrece
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
|
||||
// Inicializa las opciones
|
||||
struct options_t *options = new options_t;
|
||||
initOptions(options);
|
||||
@@ -36,7 +35,7 @@ int main(int argc, char *argv[])
|
||||
options->screen.nativeHeight = 240;
|
||||
options->screen.nativeZoom = 1;
|
||||
options->screen.windowZoom = 2;
|
||||
options->console = true;
|
||||
options->console = false;
|
||||
|
||||
// Inicializa la lista de recursos
|
||||
Asset *asset = new Asset(argv[0]);
|
||||
@@ -56,6 +55,7 @@ int main(int argc, char *argv[])
|
||||
// Inicializa SDL y la ventana
|
||||
SDL_Init(SDL_INIT_EVERYTHING);
|
||||
window = SDL_CreateWindow("jail_engine_demo", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, options->screen.nativeWidth * options->screen.nativeZoom * options->screen.windowZoom, options->screen.nativeHeight * options->screen.nativeZoom * options->screen.windowZoom, SDL_WINDOW_SHOWN);
|
||||
// window = SDL_CreateWindow("jail_engine_demo", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 320, 240, SDL_WINDOW_SHOWN);
|
||||
if (window != nullptr)
|
||||
{
|
||||
renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);
|
||||
@@ -72,13 +72,10 @@ int main(int argc, char *argv[])
|
||||
|
||||
// Inicializa jail_audio
|
||||
JA_Init(48000, AUDIO_S16, 2);
|
||||
|
||||
JA_Music_t *music;
|
||||
JA_Sound_t *sound;
|
||||
|
||||
music = JA_LoadMusic(asset->get("music.ogg").c_str());
|
||||
sound = JA_LoadSound(asset->get("sound.wav").c_str());
|
||||
int volume = 128;
|
||||
|
||||
// Inicializa el objeto screen
|
||||
Screen *screen = new Screen(window, renderer, options);
|
||||
@@ -101,7 +98,7 @@ int main(int argc, char *argv[])
|
||||
sprite->setVelY(2);
|
||||
|
||||
// Bucle principal
|
||||
// JA_PlayMusic(music, true);
|
||||
JA_PlayMusic(music, true);
|
||||
bool should_exit = false;
|
||||
while (!should_exit)
|
||||
{
|
||||
@@ -206,6 +203,8 @@ int main(int argc, char *argv[])
|
||||
// Dibuja en pantalla
|
||||
screen->start();
|
||||
screen->clean();
|
||||
// SDL_SetRenderDrawColor(renderer, 0, 0, 0, 0xFF);
|
||||
// SDL_RenderClear(renderer);
|
||||
|
||||
// Dibuja un degradado de fondo
|
||||
const int gradFirstLine = options->screen.nativeHeight / 3;
|
||||
@@ -233,29 +232,54 @@ int main(int argc, char *argv[])
|
||||
|
||||
// Vuelca el buffer en pantalla
|
||||
screen->blit();
|
||||
// SDL_RenderPresent(renderer);
|
||||
}
|
||||
|
||||
// Finaliza el sprite
|
||||
if (sprite != nullptr)
|
||||
{
|
||||
delete sprite;
|
||||
}
|
||||
if (texture != nullptr)
|
||||
{
|
||||
delete texture;
|
||||
}
|
||||
|
||||
// Finaliza el texto
|
||||
if (text != nullptr)
|
||||
{
|
||||
delete text;
|
||||
}
|
||||
|
||||
// Finaliza el objeto screen
|
||||
if (screen != nullptr)
|
||||
{
|
||||
delete screen;
|
||||
}
|
||||
|
||||
// Finaliza jail_audio
|
||||
JA_DeleteSound(sound);
|
||||
JA_DeleteMusic(music);
|
||||
|
||||
// Finaliza el objeto con la lista de recuros
|
||||
if (asset != nullptr)
|
||||
{
|
||||
delete asset;
|
||||
}
|
||||
|
||||
// Finaliza las opciones
|
||||
if (options != nullptr)
|
||||
{
|
||||
delete options;
|
||||
}
|
||||
|
||||
// Finaliza SDL y la ventana
|
||||
if (event != nullptr)
|
||||
{
|
||||
delete event;
|
||||
}
|
||||
SDL_DestroyRenderer(renderer);
|
||||
SDL_DestroyWindow(window);
|
||||
delete event;
|
||||
SDL_Quit();
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -148,6 +148,7 @@ animatedSprite_t loadAnimationFromFile(Texture *texture, std::string filePath, b
|
||||
// Constructor
|
||||
AnimatedSprite::AnimatedSprite(Texture *texture, SDL_Renderer *renderer, std::string file, std::vector<std::string> *buffer)
|
||||
{
|
||||
//std::cout << "Creado AnimatedSprite" << std::endl;
|
||||
// Copia los punteros
|
||||
setTexture(texture);
|
||||
setRenderer(renderer);
|
||||
@@ -176,6 +177,7 @@ AnimatedSprite::AnimatedSprite(Texture *texture, SDL_Renderer *renderer, std::st
|
||||
// Constructor
|
||||
AnimatedSprite::AnimatedSprite(SDL_Renderer *renderer, animatedSprite_t *animation)
|
||||
{
|
||||
//std::cout << "Creado AnimatedSprite" << std::endl;
|
||||
// Copia los punteros
|
||||
setTexture(animation->texture);
|
||||
setRenderer(renderer);
|
||||
@@ -193,6 +195,7 @@ AnimatedSprite::AnimatedSprite(SDL_Renderer *renderer, animatedSprite_t *animati
|
||||
// Destructor
|
||||
AnimatedSprite::~AnimatedSprite()
|
||||
{
|
||||
//std::cout << "Destruido AnimatedSprite" << std::endl;
|
||||
for (auto &a : animation)
|
||||
{
|
||||
a.frames.clear();
|
||||
@@ -510,21 +513,6 @@ void AnimatedSprite::update()
|
||||
MovingSprite::update();
|
||||
}
|
||||
|
||||
// Establece el rectangulo para un frame de una animación
|
||||
void AnimatedSprite::setAnimationFrames(Uint8 index_animation, Uint8 index_frame, int x, int y, int w, int h)
|
||||
{
|
||||
animation[index_animation].frames.push_back({x, y, w, h});
|
||||
}
|
||||
|
||||
// OLD - Establece el contador para todas las animaciones
|
||||
void AnimatedSprite::setAnimationCounter(int value)
|
||||
{
|
||||
for (auto &a : animation)
|
||||
{
|
||||
a.counter = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Reinicia la animación
|
||||
void AnimatedSprite::resetAnimation()
|
||||
{
|
||||
|
||||
@@ -90,12 +90,6 @@ public:
|
||||
// Actualiza las variables del objeto
|
||||
void update();
|
||||
|
||||
// OLD - Establece el rectangulo para un frame de una animación
|
||||
void setAnimationFrames(Uint8 index_animation, Uint8 index_frame, int x, int y, int w, int h);
|
||||
|
||||
// OLD - Establece el contador para todas las animaciones
|
||||
void setAnimationCounter(int value);
|
||||
|
||||
// Reinicia la animación
|
||||
void resetAnimation();
|
||||
};
|
||||
|
||||
@@ -4,11 +4,18 @@
|
||||
// Constructor
|
||||
Asset::Asset(std::string executablePath)
|
||||
{
|
||||
//std::cout << "Construido Asset" << std::endl;
|
||||
this->executablePath = executablePath.substr(0, executablePath.find_last_of("\\/"));
|
||||
longestName = 0;
|
||||
verbose = true;
|
||||
}
|
||||
|
||||
// Destructot
|
||||
Asset::~Asset()
|
||||
{
|
||||
//std::cout << "Destruido Asset" << std::endl;
|
||||
}
|
||||
|
||||
// Añade un elemento a la lista
|
||||
void Asset::add(std::string file, enum assetType type, bool required, bool absolute)
|
||||
{
|
||||
|
||||
@@ -50,6 +50,9 @@ public:
|
||||
// Constructor
|
||||
Asset(std::string path);
|
||||
|
||||
// Destructor
|
||||
~Asset();
|
||||
|
||||
// Añade un elemento a la lista
|
||||
void add(std::string file, enum assetType type, bool required = true, bool absolute = false);
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
#include "asset.h"
|
||||
#include "input.h"
|
||||
#include "jail_audio.h"
|
||||
//#include "resource.h"
|
||||
#include "sprite.h"
|
||||
#include "text.h"
|
||||
#include "utils.h"
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
|
||||
#include "movingsprite.h"
|
||||
#include <iostream>
|
||||
|
||||
// Constructor
|
||||
MovingSprite::MovingSprite(float x, float y, int w, int h, float velx, float vely, float accelx, float accely, Texture *texture, SDL_Renderer *renderer)
|
||||
{
|
||||
//std::cout << "Construido MovingSprite" << std::endl;
|
||||
// Copia los punteros
|
||||
this->texture = texture;
|
||||
this->renderer = renderer;
|
||||
@@ -53,6 +55,12 @@ MovingSprite::MovingSprite(float x, float y, int w, int h, float velx, float vel
|
||||
currentFlipV = false;
|
||||
};
|
||||
|
||||
// Destructor
|
||||
MovingSprite::~MovingSprite()
|
||||
{
|
||||
//std::cout << "Destruido MovingSprite" << std::endl;
|
||||
}
|
||||
|
||||
// Reinicia todas las variables
|
||||
void MovingSprite::clear()
|
||||
{
|
||||
|
||||
@@ -42,6 +42,9 @@ public:
|
||||
// Constructor
|
||||
MovingSprite(float x = 0, float y = 0, int w = 0, int h = 0, float velx = 0, float vely = 0, float accelx = 0, float accely = 0, Texture *texture = nullptr, SDL_Renderer *renderer = nullptr);
|
||||
|
||||
// Destructor
|
||||
~MovingSprite();
|
||||
|
||||
// Mueve el sprite
|
||||
void move();
|
||||
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
// Constructor
|
||||
Notify::Notify(SDL_Renderer *renderer, string iconFile, string bitmapFile, string textFile, string soundFile, options_t *options)
|
||||
{
|
||||
//std::cout << "Construido Notify" << std::endl;
|
||||
|
||||
// Inicializa variables
|
||||
this->renderer = renderer;
|
||||
this->options = options;
|
||||
@@ -21,17 +23,31 @@ Notify::Notify(SDL_Renderer *renderer, string iconFile, string bitmapFile, strin
|
||||
// Destructor
|
||||
Notify::~Notify()
|
||||
{
|
||||
//std::cout << "Destruido Notify" << std::endl;
|
||||
|
||||
// Libera la memoria de los objetos
|
||||
if (iconTexture != nullptr)
|
||||
{
|
||||
delete iconTexture;
|
||||
}
|
||||
if (text != nullptr)
|
||||
{
|
||||
delete text;
|
||||
}
|
||||
JA_DeleteSound(sound);
|
||||
|
||||
for (auto notification : notifications)
|
||||
{
|
||||
if (notification.sprite != nullptr)
|
||||
{
|
||||
delete notification.sprite;
|
||||
}
|
||||
if (notification.texture != nullptr)
|
||||
{
|
||||
delete notification.texture;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Dibuja las notificaciones por pantalla
|
||||
void Notify::render()
|
||||
@@ -115,9 +131,15 @@ void Notify::clearFinishedNotifications()
|
||||
for (int i = (int)notifications.size() - 1; i >= 0; --i)
|
||||
{
|
||||
if (notifications[i].state == ns_finished)
|
||||
{
|
||||
if (notifications[i].sprite != nullptr)
|
||||
{
|
||||
delete notifications[i].sprite;
|
||||
}
|
||||
if (notifications[i].texture != nullptr)
|
||||
{
|
||||
delete notifications[i].texture;
|
||||
}
|
||||
notifications.erase(notifications.begin() + i);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,13 +5,12 @@
|
||||
// Constructor
|
||||
Screen::Screen(SDL_Window *window, SDL_Renderer *renderer, options_t *options)
|
||||
{
|
||||
//std::cout << "Construido Screen" << std::endl;
|
||||
// Inicializa variables
|
||||
this->window = window;
|
||||
this->renderer = renderer;
|
||||
this->options = options;
|
||||
|
||||
gameCanvasWidth = options->screen.nativeWidth;
|
||||
gameCanvasHeight = options->screen.nativeHeight;
|
||||
borderWidth = options->screen.borderWidth * 2;
|
||||
borderHeight = options->screen.borderHeight * 2;
|
||||
|
||||
@@ -22,7 +21,7 @@ Screen::Screen(SDL_Window *window, SDL_Renderer *renderer, options_t *options)
|
||||
borderColor = {0x00, 0x00, 0x00};
|
||||
|
||||
// Crea la textura donde se dibujan los graficos del juego
|
||||
gameCanvas = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, gameCanvasWidth, gameCanvasHeight);
|
||||
gameCanvas = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, options->screen.nativeWidth, options->screen.nativeHeight);
|
||||
if (gameCanvas == nullptr)
|
||||
{
|
||||
if (options->console)
|
||||
@@ -38,6 +37,7 @@ Screen::Screen(SDL_Window *window, SDL_Renderer *renderer, options_t *options)
|
||||
// Destructor
|
||||
Screen::~Screen()
|
||||
{
|
||||
//std::cout << "Destruido Screen" << std::endl;
|
||||
if (notify != nullptr)
|
||||
{
|
||||
delete notify;
|
||||
@@ -92,19 +92,21 @@ void Screen::setVideoMode(int videoMode)
|
||||
|
||||
if (options->screen.borderEnabled)
|
||||
{
|
||||
windowWidth = gameCanvasWidth + borderWidth;
|
||||
windowHeight = gameCanvasHeight + borderHeight;
|
||||
dest = {0 + (borderWidth / 2), 0 + (borderHeight / 2), gameCanvasWidth, gameCanvasHeight};
|
||||
windowWidth = options->screen.nativeWidth + borderWidth;
|
||||
windowHeight = options->screen.nativeHeight + borderHeight;
|
||||
dest = {0 + (borderWidth / 2), 0 + (borderHeight / 2), options->screen.nativeWidth, options->screen.nativeHeight};
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
//windowWidth = gameCanvasWidth;
|
||||
windowWidth = gameCanvasWidth * options->screen.nativeZoom * options->screen.windowZoom;
|
||||
//windowHeight = gameCanvasHeight;
|
||||
windowHeight = gameCanvasHeight * options->screen.nativeZoom * options->screen.windowZoom;
|
||||
//dest = {0, 0, gameCanvasWidth, gameCanvasHeight};
|
||||
dest = {0, 0, windowWidth, windowHeight};
|
||||
// windowWidth = options->screen.nativeWidth;
|
||||
windowWidth = options->screen.nativeWidth * options->screen.nativeZoom * options->screen.windowZoom;
|
||||
// windowHeight = options->screen.nativeHeight;
|
||||
windowHeight = options->screen.nativeHeight * options->screen.nativeZoom * options->screen.windowZoom;
|
||||
// dest = {0, 0, options->screen.nativeWidth, options->screen.nativeHeight};
|
||||
gameWidth = options->screen.nativeWidth * options->screen.nativeZoom;
|
||||
gameHeight = options->screen.nativeHeight * options->screen.nativeZoom;
|
||||
dest = {0, 0, gameWidth, gameHeight};
|
||||
}
|
||||
|
||||
// Modifica el tamaño de la ventana
|
||||
@@ -127,20 +129,20 @@ void Screen::setVideoMode(int videoMode)
|
||||
{
|
||||
// Calcula el tamaño de la escala máxima
|
||||
int scale = 0;
|
||||
while (((gameCanvasWidth * (scale + 1)) <= windowWidth) && ((gameCanvasHeight * (scale + 1)) <= windowHeight))
|
||||
while (((options->screen.nativeWidth * (scale + 1)) <= windowWidth) && ((options->screen.nativeHeight * (scale + 1)) <= windowHeight))
|
||||
{
|
||||
scale++;
|
||||
}
|
||||
|
||||
dest.w = gameCanvasWidth * scale;
|
||||
dest.h = gameCanvasHeight * scale;
|
||||
dest.w = options->screen.nativeWidth * scale;
|
||||
dest.h = options->screen.nativeHeight * scale;
|
||||
dest.x = (windowWidth - dest.w) / 2;
|
||||
dest.y = (windowHeight - dest.h) / 2;
|
||||
}
|
||||
else if (options->screen.keepAspect)
|
||||
{
|
||||
float ratio = (float)gameCanvasWidth / (float)gameCanvasHeight;
|
||||
if ((windowWidth - gameCanvasWidth) >= (windowHeight - gameCanvasHeight))
|
||||
float ratio = (float)options->screen.nativeWidth / (float)options->screen.nativeHeight;
|
||||
if ((windowWidth - options->screen.nativeWidth) >= (windowHeight - options->screen.nativeHeight))
|
||||
{
|
||||
dest.h = windowHeight;
|
||||
dest.w = (int)((windowHeight * ratio) + 0.5f);
|
||||
@@ -164,7 +166,8 @@ void Screen::setVideoMode(int videoMode)
|
||||
}
|
||||
|
||||
// Modifica el tamaño del renderizador
|
||||
SDL_RenderSetLogicalSize(renderer, windowWidth, windowHeight);
|
||||
// SDL_RenderSetLogicalSize(renderer, windowWidth, windowHeight);
|
||||
SDL_RenderSetLogicalSize(renderer, gameWidth, gameHeight);
|
||||
|
||||
// Actualiza las opciones
|
||||
options->screen.mode = videoMode;
|
||||
@@ -302,7 +305,7 @@ void Screen::renderFade()
|
||||
return;
|
||||
}
|
||||
|
||||
const SDL_Rect rect = {0, 0, gameCanvasWidth, gameCanvasHeight};
|
||||
const SDL_Rect rect = {0, 0, options->screen.nativeWidth, options->screen.nativeHeight};
|
||||
color_t color = {0, 0, 0};
|
||||
const float step = (float)fadeCounter / (float)fadeLenght;
|
||||
const int alpha = 0 + (255 - 0) * step;
|
||||
|
||||
@@ -22,12 +22,12 @@ private:
|
||||
Notify *notify; // Dibuja notificaciones por pantalla
|
||||
|
||||
// Variables
|
||||
int windowWidth; // Ancho de la pantalla o ventana
|
||||
int windowHeight; // Alto de la pantalla o ventana
|
||||
int gameCanvasWidth; // Resolución interna del juego. Es el ancho de la textura donde se dibuja el juego
|
||||
int gameCanvasHeight; // Resolución interna del juego. Es el alto de la textura donde se dibuja el juego
|
||||
int borderWidth; // Anchura del borde
|
||||
int borderHeight; // Anltura del borde
|
||||
int borderWidth; // Anchura del borde que se añade a la resolución nativa del juego
|
||||
int borderHeight; // Anltura del borde que se añade a la resolución nativa del juego
|
||||
int gameWidth; // Resultado de multiplicar la resolución nativa (mas el borde) por el zoom nativo
|
||||
int gameHeight; // Resultado de multiplicar la resolución nativa (mas el borde) por el zoom nativo
|
||||
int windowWidth; // Resultado de multiplicar gameWidth por el zoom de la ventana
|
||||
int windowHeight; // Resultado de multiplicar gameWidth por el zoom de la ventana
|
||||
SDL_Rect dest; // Coordenadas donde se va a dibujar la textura del juego sobre la pantalla o ventana
|
||||
color_t borderColor; // Color del borde añadido a la textura de juego para rellenar la pantalla
|
||||
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
#include "sprite.h"
|
||||
#include <iostream>
|
||||
|
||||
// Constructor
|
||||
Sprite::Sprite(int x, int y, int w, int h, Texture *texture, SDL_Renderer *renderer)
|
||||
{
|
||||
//std::cout << "Construido Sprite" << std::endl;
|
||||
// Establece la posición X,Y del sprite
|
||||
this->x = x;
|
||||
this->y = y;
|
||||
@@ -28,6 +30,7 @@ Sprite::Sprite(int x, int y, int w, int h, Texture *texture, SDL_Renderer *rende
|
||||
|
||||
Sprite::Sprite(SDL_Rect rect, Texture *texture, SDL_Renderer *renderer)
|
||||
{
|
||||
//std::cout << "Construido Sprite" << std::endl;
|
||||
// Establece la posición X,Y del sprite
|
||||
this->x = rect.x;
|
||||
this->y = rect.y;
|
||||
@@ -51,6 +54,12 @@ Sprite::Sprite(SDL_Rect rect, Texture *texture, SDL_Renderer *renderer)
|
||||
zoomH = 1.0f;
|
||||
}
|
||||
|
||||
// Destructor
|
||||
Sprite::~Sprite()
|
||||
{
|
||||
//std::cout << "Destruido Sprite" << std::endl;
|
||||
}
|
||||
|
||||
// Muestra el sprite por pantalla
|
||||
void Sprite::render()
|
||||
{
|
||||
|
||||
@@ -29,6 +29,9 @@ public:
|
||||
Sprite(int x = 0, int y = 0, int w = 0, int h = 0, Texture *texture = nullptr, SDL_Renderer *renderer = nullptr);
|
||||
Sprite(SDL_Rect rect, Texture *texture, SDL_Renderer *renderer);
|
||||
|
||||
// Destructor
|
||||
~Sprite();
|
||||
|
||||
// Muestra el sprite por pantalla
|
||||
void render();
|
||||
|
||||
|
||||
@@ -79,6 +79,7 @@ textFile_t LoadTextFile(string file, bool verbose)
|
||||
// Constructor
|
||||
Text::Text(string textFile, string bitmapFile, SDL_Renderer *renderer)
|
||||
{
|
||||
//std::cout << "Construido Text" << std::endl;
|
||||
// Carga los offsets desde el fichero
|
||||
textFile_t tf = LoadTextFile(textFile);
|
||||
|
||||
@@ -104,6 +105,7 @@ Text::Text(string textFile, string bitmapFile, SDL_Renderer *renderer)
|
||||
// Constructor
|
||||
Text::Text(string textFile, Texture *texture, SDL_Renderer *renderer)
|
||||
{
|
||||
//std::cout << "Construido Text" << std::endl;
|
||||
// Carga los offsets desde el fichero
|
||||
textFile_t tf = LoadTextFile(textFile);
|
||||
|
||||
@@ -128,6 +130,7 @@ Text::Text(string textFile, Texture *texture, SDL_Renderer *renderer)
|
||||
// Constructor
|
||||
Text::Text(textFile_t *textFile, Texture *texture, SDL_Renderer *renderer)
|
||||
{
|
||||
//std::cout << "Construido Text" << std::endl;
|
||||
// Inicializa variables desde la estructura
|
||||
boxHeight = textFile->boxHeight;
|
||||
boxWidth = textFile->boxWidth;
|
||||
@@ -148,9 +151,14 @@ Text::Text(textFile_t *textFile, Texture *texture, SDL_Renderer *renderer)
|
||||
|
||||
// Destructor
|
||||
Text::~Text()
|
||||
{
|
||||
//std::cout << "Destruido Text" << std::endl;
|
||||
if (sprite != nullptr)
|
||||
{
|
||||
delete sprite;
|
||||
if (texture)
|
||||
}
|
||||
|
||||
if (texture != nullptr)
|
||||
{
|
||||
delete texture;
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
// Constructor
|
||||
Texture::Texture(SDL_Renderer *renderer, std::string path, bool verbose)
|
||||
{
|
||||
//std::cout << "Construido Texture" << std::endl;
|
||||
// Copia punteros
|
||||
this->renderer = renderer;
|
||||
this->path = path;
|
||||
@@ -26,6 +27,8 @@ Texture::Texture(SDL_Renderer *renderer, std::string path, bool verbose)
|
||||
// Destructor
|
||||
Texture::~Texture()
|
||||
{
|
||||
//std::cout << "Destruido Texture" << std::endl;
|
||||
|
||||
// Libera memoria
|
||||
unload();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user