-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathHealthBar.cpp
30 lines (22 loc) · 870 Bytes
/
HealthBar.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include "HealthBar.h"
#include "util.h"
extern GLuint healthBarShaderID;
float health = 0.3f;
HealthBar::HealthBar(Player * o) : GameObject(HEALTHBAR_MODEL) {
mModel.scaling = glm::vec3(HEALTHBAR_LENGTH, HEALTHBAR_SCALING, 1.0f);
origin = o;
}
void HealthBar::update() {
if (origin != 0) {
mModel.position = origin->mModel.position;
mModel.position.y += HEALTHBAR_HEIGHT;
}
}
void HealthBar::render(GLuint shaderID, glm::mat4 MVP, Camera camera, Lights lights, glm::mat4 shadowMVP) {
glUseProgram(healthBarShaderID);
GLint healthID = glGetUniformLocation(healthBarShaderID, "HEALTH");
if (origin != 0) {
if (healthID != -1) glUniform1f(healthID, origin->health);
} else if (healthID != -1) glUniform1f(healthID, 1.0f);
GameObject::render(healthBarShaderID, MVP, camera, *(new Lights()), shadowMVP);
}