Añadida la clase debug
This commit is contained in:
59
source/debug.cpp
Normal file
59
source/debug.cpp
Normal file
@@ -0,0 +1,59 @@
|
||||
#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;
|
||||
|
||||
for (auto s : slot)
|
||||
{
|
||||
text->write(x, y, s);
|
||||
y += text->getCharacterSize() + 1;
|
||||
}
|
||||
}
|
||||
|
||||
// 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();
|
||||
}
|
||||
Reference in New Issue
Block a user