-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRockleeTower.cpp
41 lines (32 loc) · 967 Bytes
/
RockleeTower.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
/** @file RockleeTower.cpp
@brief This file contains member function definitions for the RockleeTower class.
RockleeTower fires projectiles at enemies.
*/
#include "RockleeTower.h"
#include <QTimer>
#include "Projectile.h"
#include "Game.h"
extern Game* game;
RockleeTower::RockleeTower(QGraphicsItem *parent)
{
// connect a timer to attack_target
QTimer* timer = new QTimer();
connect(timer,SIGNAL(timeout()),this,SLOT(aquire_target()));
timer->start(1230); //fire rate
}
void RockleeTower::fire()
{
// create the Projectiles
Projectile * projectile = new Projectile();
// set the graphics
projectile->setPixmap(QPixmap(":/images/kick.png"));
projectile->setPos(x()+40,y()+50);
QLineF ln(QPointF(x()+40,y()+50),attack_dest);
int angle = -1 * ln.angle();
projectile->setRotation(angle+(rand()%41-20));
game->scene->addItem(projectile);
}
void RockleeTower::aquire_target()
{
Tower::aquire_target();
}