-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcannon.cpp
More file actions
44 lines (42 loc) · 741 Bytes
/
Copy pathcannon.cpp
File metadata and controls
44 lines (42 loc) · 741 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
44
#include "cannon.h"
using namespace std;
//Constructor. (x,y) is initial position
cannon::cannon(int x, int y)
{
image.load("cannon.jpg");
rect = image.rect();
rect.moveTo(x,y);
fire = true;
timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(changeFire()));
}
//Return postion of element
QRect cannon::getRect()
{
return rect;
}
//Return image of element
QImage & cannon::getImage()
{
return image;
}
//Getters and Setters
void cannon::setFire(bool a)
{
fire = a;
}
bool cannon::getFire()
{
return fire;
}
//Start one second timer to reset cannon to shoot again
void cannon::reset()
{
timer->start(1000);
}
//Allow cannon to fire. Is SLOT of timer
void cannon::changeFire()
{
fire = true;
timer->stop();
}