-
Notifications
You must be signed in to change notification settings - Fork 1
/
cell.py
68 lines (54 loc) · 2.04 KB
/
cell.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# Cell module for VPyMaze by Kile Deal
from visual import box, color
class Cell(box):
def __init__(self, color=color.red, opacity=0,
length=9, width=9, height=9,
pos=(0,0,0), northWall=None, southWall=None,
westWall=None, eastWall=None, northCell=None,
southCell=None, westCell=None, eastCell=None,
iscorner=False, mazePos = []):
box.__init__(self) # super constructor
self.color = color
self.opacity = opacity
self.length = length
self.width = width
self.height = height
self.pos = pos
self.mazePos = mazePos
# The Walls of the cell (up, down, left, right)
self.northWall = northWall
self.southWall = southWall
self.westWall = westWall
self.eastWall = eastWall
# Open Paths
self.northOpen = False
self.southOpen = False
self.westOpen = False
self.eastOpen = False
self.northCell = northCell # Pointer to cell directly above
self.southCell = southCell # Pointer to cell directly below
self.westCell = westCell # Pointer to cell directly left
self.eastCell = eastCell # Pointer to cell directly right
self.openPaths = []
self.iscorner = iscorner
self.visited = False
self.pivot = False
def openPath(self, direction):
if direction == "North":
self.northOpen = True
self.openPaths.append(self.northCell)
elif direction == "South":
self.southOpen = True
self.openPaths.append(self.southCell)
elif direction == "West":
self.westOpen = True
self.openPaths.append(self.westCell)
elif direction == "East":
self.eastOpen = True
self.openPaths.append(self.eastCell)
else:
raise "Invalid <direction> specified"
def highlight(self):
self.opacity=0.5
def unhighlight(self):
self.opacity=0