diff options
Diffstat (limited to 'cell.py')
| -rw-r--r-- | cell.py | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -11,6 +11,7 @@ class Cell: self.twall = twall self.rwall = rwall self.bwall = bwall + self.visited = False def draw(self, x1, y1, x2, y2): if self._win is None: @@ -26,8 +27,11 @@ class Cell: self._win.draw_line(Line(Point(x1, y2), Point(x2, y2))) if self.bwall else self._win.draw_line(Line(Point(x1, y2), Point(x2, y2)), "white") def draw_move(self, to_cell, undo=False): - center_start = Point((self._x1+self._x2)>>1, (self._y1+self._y2)>>1) - center_end = Point((to_cell._x1+to_cell._x2)>>1, (to_cell._y1+to_cell._y2)>>1) + half_length_start = abs(self._x2 - self._x1) // 2 + center_start = Point(self._x1 + half_length_start, self._y1 + half_length_start) + + half_length_end = abs(to_cell._x2 - to_cell._x1) // 2 + center_end = Point(to_cell._x1 + half_length_end, to_cell._y1 + half_length_end) fill_color = "red" if undo: fill_color = "gray" |
