-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathattacker.cpp
More file actions
53 lines (44 loc) · 712 Bytes
/
attacker.cpp
File metadata and controls
53 lines (44 loc) · 712 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
#include "attacker.h"
attacker::attacker() {}
attacker::attacker(int pX)
{
image.load("attacker.png");
rect = image.rect();
rect.moveTo(700,700);
int temp = 600 - rect.width();
x = rand() % temp;
y = 25;
targetX = pX;
active = true;
}
void attacker::reset()
{
rect.moveTo(x,y);
}
void attacker::advance()
{
if (targetX > x) { x++; }
else if (targetX < x) { x--; }
y += 3;
rect.moveTo(x,y);
}
void attacker::remove()
{
rect.moveTo(700,700);
}
QRectF attacker::getRectF()
{
return rect;
}
void attacker::didCollide()
{
active = false;
}
bool attacker::isActive()
{
return active;
}
QImage attacker::getImage()
{
return image;
}