forked from jaildesigner-jailgames/jaildoctors_dilemma
67 lines
1.1 KiB
C++
67 lines
1.1 KiB
C++
#include "debug.h"
|
|
|
|
// Constructor
|
|
Debug::Debug(SDL_Renderer *renderer, Screen *screen, Asset *asset)
|
|
{
|
|
// Copia la dirección de los objetos
|
|
this->renderer = renderer;
|
|
this->screen = screen;
|
|
this->asset = asset;
|
|
|
|
// Reserva memoria para los punteros
|
|
text = new Text(asset->get("debug.png"), asset->get("debug.txt"), renderer);
|
|
|
|
// Inicializa variables
|
|
x = 0;
|
|
y = 0;
|
|
}
|
|
|
|
// Destructor
|
|
Debug::~Debug()
|
|
{
|
|
delete text;
|
|
}
|
|
|
|
// Actualiza las variables
|
|
void Debug::update()
|
|
{
|
|
}
|
|
|
|
// Dibuja en pantalla
|
|
void Debug::render()
|
|
{
|
|
int y = this->y;
|
|
int w = 0;
|
|
|
|
for (auto s : slot)
|
|
{
|
|
text->write(x, y, s);
|
|
w = (std::max(w, (int)s.length()));
|
|
y += text->getCharacterSize() + 1;
|
|
if (y > 192 - text->getCharacterSize())
|
|
{
|
|
y = this->y;
|
|
x += w*text->getCharacterSize() + 2;
|
|
}
|
|
}
|
|
}
|
|
|
|
// Establece la posición donde se colocará la información de debug
|
|
void Debug::setPos(SDL_Point p)
|
|
{
|
|
x = p.x;
|
|
y = p.y;
|
|
}
|
|
|
|
// Añade un texto para mostrar
|
|
void Debug::add(std::string text)
|
|
{
|
|
slot.push_back(text);
|
|
}
|
|
|
|
// Borra la información de debug
|
|
void Debug::clear()
|
|
{
|
|
slot.clear();
|
|
}
|