/
StrongUnit.cpp
76 lines (63 loc) · 1.63 KB
/
StrongUnit.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#include "StrongUnit.h"
#include "constants.h"
#include "lighting.h"
#include "models.h"
#include "shadow.h"
namespace s_unit {
const int MAX_HP = unit_health::STRONG;
const int ATK = 8;
const float SPD = unit_speed::STRONG;
}
using namespace s_unit;
StrongUnit::StrongUnit(float inx, float iny, float inz):
Unit(inx, iny, inz)
{
hp = MAX_HP;
max_hp = MAX_HP;
atk_dmg = ATK;
speed = SPD;
max_speed = SPD;
type = U_STRONG;
value = unit_bonus::STRONG;
animateSpeed = 0.25;
}
StrongUnit::~StrongUnit(void) {
}
unit_dir StrongUnit::move(unit_dir direction) {
return direction;
}
void StrongUnit::draw() {
glPushMatrix();
glTranslatef(x, y, z);
glPushMatrix();
glPushMatrix();
glTranslatef(0.0,1.2,0.0);
this->drawHealthBar();
glPopMatrix();
if (animateSpeed >= 1) {
animateSpeed = 0.25;
}
glScaled(0.25, 0.25, 0.25);
glTranslatef(0, 1, 0);
double dist = sqrt((getX() - cam.getCamX()) * (getX() - cam.getCamX())
+ (getY() - cam.getCamY()) * (getY() - cam.getCamY())
+ (getZ() - cam.getCamZ()) * (getZ() - cam.getCamZ()));
if (dist <= 10) {
drawForkBombDLAnimated(animateSpeed+=0.01, 3);
} else if (dist <= 11.5) {
drawForkBombDLAnimated(animateSpeed+=0.01, 2);
} else {
drawForkBombDLAnimated(animateSpeed+=0.01, 1);
}
// glCallList(vtd_dl::forkbDL);
//glCallList(vtd_dl::virusDL);
glPopMatrix();
glPushMatrix();
draw_shadow(9);
glPopMatrix();
glPopMatrix();
}
//void StrongUnit::step(float dt) {
//will be changed by waypoint
// z = z + dt;
//}