-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBox.py
53 lines (44 loc) · 1.43 KB
/
Box.py
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
from PyQt4 import QtGui
class Box(QtGui.QLabel):
def __init__(self, parent=None, symbol='#'):
super(Box, self).__init__(parent)
self.is_walkable = False
self.is_monster = False
self.is_magic = False
self.is_end = False
self.is_hero = False
self.gp = None
self.wp = None
self.hp = None
self.magp = None
self.monp = None
self.ep = None
self._init(symbol)
def _init(self, symbol):
self.gp = QtGui.QPixmap('green.png')
self.wp = QtGui.QPixmap('wall.png')
self.hp = QtGui.QPixmap('hero.png')
self.magp = QtGui.QPixmap('magic.png')
self.monp = QtGui.QPixmap('monster.png')
self.ep = QtGui.QPixmap('end.png')
if symbol == '#':
self.setPixmap(self.wp)
elif symbol == ' ':
self.setPixmap(self.gp)
self.is_walkable = True
elif symbol == '$':
self.setPixmap(self.hp)
self.is_hero = True
self.is_walkable = True
elif symbol == '*':
self.setPixmap(self.magp)
self.is_magic = True
self.is_walkable = True
elif symbol == '@':
self.setPixmap(self.monp)
self.is_monster = True
self.is_walkable = True
elif symbol == 'E':
self.setPixmap(self.ep)
self.is_end = True
self.is_walkable = True