-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathShikamaruTower.cpp
74 lines (52 loc) · 1.87 KB
/
ShikamaruTower.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
67
68
69
70
71
72
73
74
/** @file ShikamaruTower.cpp
@brief This file contains member function definitions for the ShikamaruTower class.
ShikamaruTower fires multiple projectiles in a spread.
*/
#include "ShikamaruTower.h"
#include <QTimer>
#include "Projectile.h"
#include "Game.h"
extern Game* game;
ShikamaruTower::ShikamaruTower(QGraphicsItem *parent)
{
// connect a timer to attack_target
QTimer* timer = new QTimer();
connect(timer,SIGNAL(timeout()),this,SLOT(aquire_target()));
timer->start(6000); //fire rate
}
void ShikamaruTower::fire()
{
// create the Projectiles
Projectile * Projectile2 = new Projectile();
Projectile * Projectile3 = new Projectile();
Projectile * Projectile4 = new Projectile();
Projectile * Projectile5 = new Projectile();
Projectile * Projectile6 = new Projectile();
// set the graphics
Projectile2->setPixmap(QPixmap(":/images/shadow.png"));
Projectile3->setPixmap(QPixmap(":/images/shadow.png"));
Projectile4->setPixmap(QPixmap(":/images/shadow.png"));
Projectile5->setPixmap(QPixmap(":/images/shadow.png"));
Projectile6->setPixmap(QPixmap(":/images/shadow.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);
Projectile6->setPos(x()+40,y()+50);
QLineF ln(QPointF(x()+40,y()+50),attack_dest);
int angle = -1 * ln.angle();
Projectile2->setRotation(angle+25);
Projectile3->setRotation(angle-25);
Projectile4->setRotation(angle+30);
Projectile5->setRotation(angle-30);
Projectile6->setRotation(angle);
game->scene->addItem(Projectile2);
game->scene->addItem(Projectile3);
game->scene->addItem(Projectile4);
game->scene->addItem(Projectile5);
game->scene->addItem(Projectile6);
}
void ShikamaruTower::aquire_target()
{
Tower::aquire_target();
}