-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsword.h
50 lines (45 loc) · 948 Bytes
/
sword.h
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
#ifndef SWORD_H_
#define SWORD_H_
#include "lozobj.h"
class Sword : public LoZObject { //Link's trusty sword. That is all. It exists in the square in front of Link.
private:
int dir;
public:
Sword(int m, int n) : LoZObject(m, n) {
dir = 6;
id = 'l';
}
void reposition(int m, int n, int d) {
dir = d;
switch (d) {
case 2: y = n + 30;
x = m + 10;
break;
case 4: y = n + 10;
x = m - 30;
break;
case 6: y = n + 10;
x = m + 30;
break;
case 8: y = n - 30;
x = m + 10;
break;
}
}
void draw(QPainter& g) {
g.setPen(QPen(QColor(50,50,50)));
g.setBrush(QBrush(QColor(177,177,177), Qt::SolidPattern));
if (dir == 4 || dir == 6) {
g.drawRect(x, y, 30, 10);
}
else {
g.drawRect(x, y, 10, 30);
}
}
QRect getWrecked() {
if (dir == 4 || dir == 6)
return QRect(x, y, 30, 10);
return QRect(x, y, 10, 30);
}
};
#endif