fix(visualizer): do not close window when path has finished moving
This commit is contained in:
@@ -39,27 +39,27 @@ class Visualizer:
|
|||||||
|
|
||||||
self.screen.fill((0, 0, 0))
|
self.screen.fill((0, 0, 0))
|
||||||
|
|
||||||
|
if self.idx < len(self.positions):
|
||||||
pos = self.positions[self.idx]
|
pos = self.positions[self.idx]
|
||||||
x, y, z = self._transform_coordinates(pos)
|
x, y, z = self._transform_coordinates(pos)
|
||||||
if self.prev_z < 0 and z < 0:
|
if self.prev_z < 0 and z < 0:
|
||||||
self.drawn_lines.append((self.prev_x, self.prev_y, x, y))
|
self.drawn_lines.append((self.prev_x, self.prev_y, x, y))
|
||||||
elif z > 0:
|
elif z > 0:
|
||||||
self.travel_moves.append((self.prev_x, self.prev_y, x, y))
|
self.travel_moves.append((self.prev_x, self.prev_y, x, y))
|
||||||
# Draw travel moves
|
|
||||||
for travel_move in self.travel_moves:
|
|
||||||
x1, y1, x2, y2 = travel_move
|
|
||||||
# Draw a line from the previous position to the current position
|
|
||||||
pygame.draw.line(self.screen, (0, 0, 255), (int(x1), int(y1)), (int(x2), int(y2)), 2)
|
|
||||||
for drawn_line in self.drawn_lines:
|
|
||||||
x1, y1, x2, y2 = drawn_line
|
|
||||||
# Draw a line from the previous position to the current position
|
|
||||||
pygame.draw.line(self.screen, (255, 255, 255), (int(x1), int(y1)), (int(x2), int(y2)), 2)
|
|
||||||
self.prev_x, self.prev_y, self.prev_z = x, y, z
|
self.prev_x, self.prev_y, self.prev_z = x, y, z
|
||||||
# Draw the current position
|
# Draw the current position
|
||||||
pygame.draw.circle(self.screen, (255, 0, 0), (int(x), int(y)), 5)
|
pygame.draw.circle(self.screen, (255, 0, 0), (int(x), int(y)), 5)
|
||||||
self.idx += 1
|
self.idx += 1
|
||||||
if self.idx >= len(self.positions):
|
|
||||||
running = False
|
# Draw travel moves
|
||||||
|
for travel_move in self.travel_moves:
|
||||||
|
x1, y1, x2, y2 = travel_move
|
||||||
|
pygame.draw.line(self.screen, (0, 0, 255), (int(x1), int(y1)), (int(x2), int(y2)), 2)
|
||||||
|
|
||||||
|
# Draw drawn lines
|
||||||
|
for drawn_line in self.drawn_lines:
|
||||||
|
x1, y1, x2, y2 = drawn_line
|
||||||
|
pygame.draw.line(self.screen, (255, 255, 255), (int(x1), int(y1)), (int(x2), int(y2)), 2)
|
||||||
|
|
||||||
pygame.display.flip()
|
pygame.display.flip()
|
||||||
self.clock.tick(10)
|
self.clock.tick(60)
|
||||||
Reference in New Issue
Block a user