-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy paththirdtower.cpp
More file actions
43 lines (34 loc) · 879 Bytes
/
thirdtower.cpp
File metadata and controls
43 lines (34 loc) · 879 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
#include "ThirdTower.h"
#include <QTimer>
#include "bullet.h"
#include "game.h"
#include <QLineF>
extern Game *game;
ThirdTower::ThirdTower(QGraphicsItem *parent)
{
//set tower
setPixmap(QPixmap(":/images/thirdtower.png"));
//connect timer to attack
QTimer *timer = new QTimer();
connect(timer,SIGNAL(timeout()),this,SLOT(acquire_target()));
timer->start(1000);
//attack color
QPen pen;
pen.setColor(Qt::red);
attack_area->setPen(pen);
}
void ThirdTower::fire()
{
Bullet *bullet = new Bullet();
//set graphics
bullet->setPixmap(QPixmap(":/images/thirdtowerbullet.png"));
bullet->setPos(x()+50,y()+50);
QLineF ln(QPoint(x()+50,y()+50),attack_dest);
int angle = -1*ln.angle();
bullet->setRotation(angle);
scene()->addItem(bullet);
}
void ThirdTower::acquire_target()
{
Tower::acquire_target();
}