-
Notifications
You must be signed in to change notification settings - Fork 0
/
weapon.cpp
105 lines (92 loc) · 1.25 KB
/
weapon.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#include "weapon.h"
#include <iostream>
using namespace std;
Weapon::Weapon(QString filename, int xD, int yD)
{
image.load(filename);
rect = image.rect();
active = false;
xDir = xD;
yDir = yD;
}
Weapon::~Weapon()
{
cout<<"Weapon deleted."<<endl;
}
void Weapon::setPosition(int xPos, int yPos)
{
rect.moveTo(xPos, yPos);
}
void Weapon::resetState()
{
rect.moveTo(10,10);
active = false;
}
bool Weapon::isActive()
{
return active;
}
void Weapon::setActive(bool b)
{
active = b;
}
QRect Weapon::getRect()
{
return rect;
}
void Weapon::setRect(QRect r)
{
rect = r;
}
QImage & Weapon::getImage()
{
return image;
}
void Weapon::moveTop(int top)
{
rect.moveTop(top);
}
void Weapon::moveBottom(int bottom)
{
rect.moveBottom(bottom);
}
void Weapon::moveRight(int right)
{
rect.moveRight(right);
}
void Weapon::moveLeft(int left)
{
rect.moveLeft(left);
}
void Weapon::autoMove()
{
rect.translate(xDir, yDir);
/**if (rect.top() <= 10)
{
active = false;
}
if (rect.bottom() >= 340)
{
active = false;
}
if (rect.right() <= 1 || rect.left() >= 599)
{
xDir = -xDir;
} */
}
int Weapon::getXDir()
{
return xDir;
}
void Weapon::setXDir(int xD)
{
xDir = xD;
}
int Weapon::getYDir()
{
return yDir;
}
void Weapon::setYDir(int yD)
{
yDir = yD;
}