Fixed text color and removed debugging code

This commit is contained in:
viktorljung
2016-01-24 13:37:07 +01:00
parent fcba0a28b8
commit aa3b8cd652
2 changed files with 123 additions and 44 deletions
+2 -24
View File
@@ -11,32 +11,12 @@ PlayerHUD::PlayerHUD(World* world, EventBroker* eventBrokerer)
PlayerHUD::~PlayerHUD()
{
//
}
void PlayerHUD::Update(double dt)
{
if(ImGui::Button("Set Camera", ImVec2(70, 20))){
auto cameras = m_World->GetComponents("Camera");
if(cameras == nullptr) {
return;
}
EntityWrapper ew = EntityWrapper(m_World, (*cameras->begin()).EntityID);
if (ew.Valid()) {
Events::SetCamera e;
e.CameraEntity = ew;
m_EventBroker->Publish(e);
} else {
LOG_INFO("Coulnd't find a camera");
}
}
auto healthHUDs = m_World->GetComponents("HealthHUD");
if (healthHUDs == nullptr) {
return;
@@ -57,14 +37,12 @@ void PlayerHUD::Update(double dt)
if (entityIDParent.HasComponent("Health")) {
if (entity.HasComponent("Text")) {
std::string s = "";
s = s + std::to_string((int)(double)entityIDParent["Health"]["Health"]);
s = s + "/";
s = s + std::to_string((int)(double)entityIDParent["Health"]["MaxHealth"]);
float healthPercentage = (double)entityIDParent["Health"]["Health"]/(double)entityIDParent["Health"]["MaxHealth"];
(glm::vec4&) entity["Text"]["Color"] = glm::vec4(1.0 - healthPercentage, healthPercentage, 0.f, 0.f);
(glm::vec4&)entity["Text"]["Color"] = glm::vec4(1.0 - healthPercentage, 0.f, healthPercentage, 1.f);
entity["Text"]["Content"] = s;
}