-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathenemy.h
77 lines (70 loc) · 1.59 KB
/
enemy.h
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
66
67
68
69
70
71
72
73
74
75
76
77
#ifndef ENEMY_H
#define ENEMY_H
#include <QGraphicsPixmapItem>
#include <QObject>
#include <QKeyEvent>
#include <QList>
#include <QGraphicsScene>
#include <QTimer>
#include <QObject>
#include <QGraphicsItemGroup>
#include "castle.h"
#include "fence.h"
#include "node.h"
using namespace std;
class Enemy: public QObject, public QGraphicsPixmapItem
{
Q_OBJECT
private:
int imgLen;
double velocity[5] = {2.5, 2.75, 3, 3.25, 3.4};
int healthVal[5] = {50, 55, 60, 70, 80};
int damageVal[5] = {5, 10, 20, 25, 30};
int health;
// images of the enemy in different positions
QStringList attackImgs;
QStringList walkImgs;
// timers
QTimer* moveTimer;
QTimer* damageTimer;
QTimer* attackTimer;
QTimer* walkTimer;
Castle* castle;
int damage;
HealthBar* healthBar;
bool isHealthBarShown;
bool finished = false;
vector<Node*> path;
// test
// QGraphicsItemGroup* group;
//contact with the fence
bool work = false;
bool contact = false;
double offsetX = 0;
double offsetY = 0;
double STEP_SIZE;
int row;
int col;
int curr;
public slots:
void moveRandomly();
void moveHealthBar();
public:
Enemy(int,int);
~Enemy();
int getHealth();
void setHealth(int);
void decrementHealth(int);
void incrementHealth(int);
void attackAnimate();
void attackFence(Fence*&);
void attackCastle();
void updatePath();
void setRow(int r);
void setCol(int c);
void setCurr(int c);
int getRow() const;
int getCol() const;
int getCurr() const;
};
#endif // ENEMY_H