-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathZombie.cpp
More file actions
63 lines (53 loc) · 992 Bytes
/
Zombie.cpp
File metadata and controls
63 lines (53 loc) · 992 Bytes
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
#include <cstdlib>
#include <math.h>
#include "Zombie.h"
Zombie::Zombie()
{
switch (rand() % 4)
{
case 0:
y = 0;
x = rand() % width;
break;
case 1:
y = height;
x = rand() % width;
break;
case 2:
y = rand() % height;
x = 0;
break;
case 3:
y = rand() % height;
x = width;
break;
}
size = 5;
}
Zombie::Zombie(double xin, double yin)
{
x = xin;
y = yin;
size = 5;
}
Zombie::~Zombie()
{
}
const double ZOMBIE_SPEED = 3.5;
void Zombie::update()
{
GenericObject* player = ThePlayer;
double delta_y = (player->y) - y;
double delta_x = (player->x) - x;
angle = atan2(delta_y, delta_x);
x += ZOMBIE_SPEED * cos(angle);
y += ZOMBIE_SPEED * sin(angle);
angle = angle * 180 / PI;//convert to degrees
possibleCollideWithFollower();
possibleCollideWithPlayer();
}
void Zombie::collideWithPlayer()
{
}
void Zombie::collideWithFollower()
{}