-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcell.py
More file actions
53 lines (48 loc) · 1.6 KB
/
cell.py
File metadata and controls
53 lines (48 loc) · 1.6 KB
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 window import Line, Point
class Cell():
def __init__(self, window=None):
self.left_wall = True
self.right_wall = True
self.top_wall = True
self.bottom_wall = True
self.x1 = None
self.y1 = None
self.x2 = None
self.y2 = None
self.win = window
self.visited = False
def draw(self, x1, y1, x2, y2):
self.x1 = x1
self.y1 = y1
self.x2 = x2
self.y2 = y2
color = "black"
if self.left_wall:
color = "#00FFFF"
line = Line(Point(self.x1, self.y1), Point(self.x1, self.y2))
self.win.draw_line(line, color)
color = "black"
if self.right_wall:
color = "#00FFFF"
line = Line(Point(self.x2, self.y1), Point(self.x2, self.y2))
self.win.draw_line(line, color)
color = "black"
if self.top_wall:
color = "#00FFFF"
line = Line(Point(self.x1, self.y1), Point(self.x2, self.y1))
self.win.draw_line(line, color)
color = "black"
if self.bottom_wall:
color = "#00FFFF"
line = Line(Point(self.x1, self.y2), Point(self.x2, self.y2))
self.win.draw_line(line, color)
def draw_move(self, to_cell, undo=False):
color = "#CCFF00"
if undo:
color = "#C71585"
midx1 = (self.x1 + self.x2)/2
midy1 = (self.y1 + self.y2)/2
midx2 = (to_cell.x1 + to_cell.x2)/2
midy2 = (to_cell.y1 + to_cell.y2)/2
line = Line(Point(midx1, midy1), Point(midx2, midy2))
self.win.draw_line(line, color)