-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdiagenemy.cpp
65 lines (53 loc) · 1.08 KB
/
diagenemy.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 "diagenemy.h"
DiagEnemy::DiagEnemy(int x, int y) : Brick(x, y)
{
image.load("diagonalEnemy.png");
hp = 1;
shoot = false;
moveRight = true;
xDir = 1;
yDir = 1;
origPosX = x;
origPosY = y;
tracker = false;
rect = image.rect();
rect.translate(x, y);
}
DiagEnemy::~DiagEnemy()
{
//std::cout << ("Basic enemy deleted\n");
}
void DiagEnemy::autoMove(int level)
{
for (int i=0; i<level; i++){
rect.translate(xDir, yDir);
if(rect.left() == 0){
moveRight = true;
xDir = 1;
}
if(rect.right() == 300){
moveRight = false;
xDir = -1;
}
if(rect.bottom() == 400){
reset();
}
}
}
void DiagEnemy::setDir(int playerX){
}
bool DiagEnemy::timeToShoot(int x)
{
if(this->getRect().x() == x){
shoot = true;
return shoot;
}
else{
shoot = false;
return shoot;
}
}
void DiagEnemy::reset()
{
rect.moveTo(origPosX, origPosY);
}