-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdoor.h
57 lines (52 loc) · 1.34 KB
/
door.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
51
52
53
54
55
56
57
#ifndef DOOR_H_
#define DOOR_H_
#include "lozobj.h"
class Door : public LoZObject { //A door that Link can go through
private:
int hash; //If 0, door is open. If not, hash is accessed in room.h to see the opening conditions.
int next;
public:
Door(int x, int y, int i, int n) : LoZObject(x, y), hash(i), next(n) { //Constructor
if (hash > 0) //Event-triggered doors
id = 'X';
else if (hash < 0) //Normal locked doors
id = '*';
else
id = 'D';
}
void draw(QPainter& g) { //Draws the door, depending on what kind of door it is.
if (hash != 0) {
g.setPen(QPen(QColor(0,64,126)));
g.setBrush(QBrush(QColor(0,64,126), Qt::SolidPattern));
g.drawRect(x, y, 29, 29);
if (id == '*') {
g.setPen(QPen(QColor(0,0,0)));
g.setBrush(QBrush(QColor(0,0,0), Qt::SolidPattern));
g.drawEllipse(x+11, y+8, 8, 8);
g.drawRect(x+13, y + 12, 4, 10);
}
}
else {
g.setPen(QPen(QColor(144,104,40)));
g.setBrush(QBrush(QColor(144,104,40), Qt::SolidPattern));
g.drawRect(x, y, 29, 29);
}
}
void setHash(int i) { //Mainly for opening/unlocking
hash = i;
if (hash != 0)
id = 'X';
else
id = 'D';
}
int getHash() { //For managing in room.h
return hash;
}
int getNext() { //To know where to go
if (hash != 0)
return -1;
else
return next;
}
};
#endif