-
Notifications
You must be signed in to change notification settings - Fork 0
/
enemy.cpp
65 lines (58 loc) · 1.38 KB
/
enemy.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
#include <zenilib.h>
#include "enemy.h"
using namespace Zeni;
using namespace Zeni::Collision;
void enemy::chase(Crate::Player &player, float & step)
{
if(!aim.is_running())aim.start();
user_pos = player.get_camera().position;
/*float x = user_pos.x-m_corner.x;
float y = user_pos.y-m_corner.y;
float z = user_pos.z-m_corner.z;
if(user_pos.x>m_corner.x)x=speed*step;
else x= -speed*step;
if(user_pos.y>m_corner.y)y=speed*step;
else y= -speed*step;
if(user_pos.z>m_corner.z)z=speed*step;
else z= -speed*step;*/
//only go chase if the enemy is not resting
if(go_chase)
{
m_corner += speed*step*direction/70.0f;
create_body();
}
}
void enemy::rest()
{
chill.set(0);
chill.start();
go_chase = false;
}
void enemy::cont_chase()
{
if(!chill.is_running() || !chill.seconds()<2.0f)
{
go_chase = true;
chill.stop();
}
}
void enemy::calc_dir()
{
if(aim.seconds()>1.0f)
{
direction = user_pos-m_corner;
aim.set(0);
aim.start();
}
}
void enemy::create_body()
{
m_body = Parallelepiped(m_corner,
m_rotation * 6.0f * m_scale.get_i(),
m_rotation * 3.0f * m_scale.get_j(),
m_rotation * 3.0f * m_scale.get_k());
}
void enemy::stop(const bool &stopit)
{
stopped = stopit;
}