-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTentenTower.cpp
66 lines (47 loc) · 1.61 KB
/
TentenTower.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
66
/** @file TentenTower.cpp
@brief This file contains member function definitions for the TentenTower class.
TentenTower fires multiple projectiles all around.
*/
#include "TentenTower.h"
#include <QTimer>
#include "Projectile.h"
#include "Game.h"
extern Game* game;
TentenTower::TentenTower(QGraphicsItem *parent)
{
// connect a timer to attack_target
QTimer* timer = new QTimer();
connect(timer,SIGNAL(timeout()),this,SLOT(aquire_target()));
timer->start(7000); //fire rate
}
void TentenTower::fire()
{
// create the Projectiles
Projectile * Projectile2 = new Projectile();
Projectile * Projectile3 = new Projectile();
Projectile * Projectile4 = new Projectile();
Projectile * Projectile5 = new Projectile();
// set the graphics
Projectile2->setPixmap(QPixmap(":/images/kunai.png"));
Projectile3->setPixmap(QPixmap(":/images/kunai.png"));
Projectile4->setPixmap(QPixmap(":/images/kunai.png"));
Projectile5->setPixmap(QPixmap(":/images/kunai.png"));
Projectile2->setPos(x()+40,y()+50);
Projectile3->setPos(x()+40,y()+50);
Projectile4->setPos(x()+40,y()+50);
Projectile5->setPos(x()+40,y()+50);
QLineF ln(QPointF(x()+40,y()+50),attack_dest);
int angle = -1 * ln.angle();
Projectile2->setRotation(angle);
Projectile3->setRotation(angle-90);
Projectile4->setRotation(angle+90);
Projectile5->setRotation(angle+180);
game->scene->addItem(Projectile2);
game->scene->addItem(Projectile3);
game->scene->addItem(Projectile4);
game->scene->addItem(Projectile5);
}
void TentenTower::aquire_target()
{
Tower::aquire_target();
}