-
Notifications
You must be signed in to change notification settings - Fork 0
/
Health.cpp
60 lines (48 loc) · 1.25 KB
/
Health.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include "Health.h"
Health::Health(void)
{
XMFLOAT4 healthColor[6];
XMFLOAT4 healthRed = XMFLOAT4(0.9f, 0.2f, 0.2f, 1.0f);
for(int i = 0; i < 6; i++)
healthColor[i] = healthRed;
body = new CubeObject(1.0f, 1.0f, 1.0f, true, healthColor);
collected = false;
}
Health::~Health(void)
{
if (body)
delete body;
body = 0;
}
GameObject* Health::getModel() { return body; }
XMFLOAT3 Health::getPos() { return XMFLOAT3(pos.x,pos.y,pos.z); }
XMFLOAT4 Health::getOri() { return ori; }
XMFLOAT4 Health::getL() { return L; }
XMFLOAT4 Health::getVel() { return vel; }
float Health::getRadius() { return 1.0f; }
void Health::setPos(XMFLOAT4 newPos)
{
pos = newPos;
body->translate(pos.x, pos.y, pos.z);
}
void Health::setOri(XMFLOAT4 newOri)
{
ori = newOri;
body->rotateX(ori.x);
body->rotateY(ori.y);
body->rotateZ(ori.z);
}
void Health::setL(XMFLOAT4 newL) { L = newL; }
void Health::setVel(XMFLOAT4 newVel) { vel = newVel; }
void Health::advance()
{
body->rotateX(L.x);
body->rotateY(L.y);
body->rotateZ(L.z);
}
bool Health::isCollected() { return collected; }
void Health::collect() { collected = true; }
void Health::translate(float dx, float dy, float dz)
{
body->translate(dx, dy, dz);
}