-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathenemy.cpp
55 lines (47 loc) · 937 Bytes
/
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
#include <GL/freeglut.h>
#include <cmath>
#include <list>
#include <stdlib.h>
#include <time.h>
#include "enemy.h"
void Enemy::set(GLfloat freqTiro, GLfloat velTiro, GLfloat vel, GLint altura)
{
Player::set(velTiro, vel);
this->freqTiro = freqTiro;
this->obstacleHeight = obstacleHeight;
}
void Enemy::set(GLfloat cx, GLfloat cy, GLfloat radius, string fill, GLint id)
{
Player::set(cx, cy, radius, fill, id);
}
void Enemy::patrol()
{
if (touchingObstacle && !isJumping())
{
setJumping(true);
return;
}
else if (!isJumping() && !touchingObstacle)
{
setgr(0);
setJumping(false);
}
if (isJumping())
{
moveY(-1);
return;
}
GLfloat rotation;
srand(time(NULL));
rotation = rand() % 2;
if (rotation <= 0.5)
{
rotate(1);
moveY(-1);
}
else
{
rotate(-1);
moveY(-1);
}
}