idEntity *ent = gLocal->entities[i]; idVec4 hColor; float healthPercent; if(ent->GetHealth() > 100){ hColor = idVec4(0.0f, 1.0f, 0.0f, 1.0f); } else if(ent->GetHealth() > 50) { //color fade from green to yellow to red. based on health percentage hColor = idVec4((1.0f-((float)ent->GetHealth()/100.0f)), 1.0f, 0.0f, 1.0f); } else if(ent->GetHealth() <= 50) { hColor = idVec4(1.0f, ((float)ent->GetHealth()/100.0f), 0.0f, 1.0f); } if(ent->GetHealth() >= 100) { healthPercent = 1.0f; }else if(ent->GetHealth() <= 0) { healthPercent = 0.0f; }else{ healthPercent = ((float)ent->GetHealth() / 100.0f); } deviceContext->DrawClippedRect(position.x-27.0f, position.y-20.0f, 54.0f, 9.0f, idVec4(0.0f, 0.0f, 0.0f, 0.5f)); deviceContext->DrawClippedRect(position.x-25.0f, position.y-18.0f, (50.0f * healthPercent), 5.0f, hColor);