OpenMiner/source/hud/DebugOverlay.cpp

46 lines
1.1 KiB
C++
Raw Normal View History

2018-07-06 14:24:49 +02:00
/*
* =====================================================================================
*
* Filename: DebugOverlay.cpp
*
* Description:
*
* Created: 06/07/2018 13:54:25
*
* Author: Quentin Bazin, <quent42340@gmail.com>
*
* =====================================================================================
*/
#include <sstream>
#include "Config.hpp"
#include "DebugOverlay.hpp"
2018-12-25 23:14:39 +01:00
#include "Player.hpp"
2018-07-06 14:24:49 +02:00
2018-12-25 23:14:39 +01:00
DebugOverlay::DebugOverlay(const Player &player) : m_player(player) {
2018-07-06 14:24:49 +02:00
setPosition(4, 4, 0);
m_versionText.setText(APP_NAME + std::string(" v0.0.1"));
2018-12-29 02:23:23 +01:00
m_versionText.setColor(gk::Color::white);
2018-07-06 14:24:49 +02:00
m_positionText.setPosition(0, 10, 0);
2018-12-29 02:23:23 +01:00
m_positionText.setColor(gk::Color::white);
2018-07-06 14:24:49 +02:00
}
void DebugOverlay::update() {
std::stringstream stream;
2018-12-25 23:14:39 +01:00
stream << "x: " << floorf(m_player.x()) << " | ";
stream << "y: " << floorf(m_player.y()) << " | ";
stream << "z: " << floorf(m_player.z());
2018-07-06 14:24:49 +02:00
m_positionText.setText(stream.str());
}
2018-12-29 02:23:23 +01:00
void DebugOverlay::draw(gk::RenderTarget &target, gk::RenderStates states) const {
states.transform *= getTransform();
2018-07-06 14:24:49 +02:00
target.draw(m_versionText, states);
target.draw(m_positionText, states);
}