Fixed text color and removed debugging code
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user