forked from seungjae02/PathfindingVisualizer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
visualize_path_class.py
29 lines (26 loc) · 909 Bytes
/
visualize_path_class.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
from settings import *
class VisualizePath():
def __init__(self, surface, start_node_x, start_node_y, path, path_coords):
self.surface = surface
self.start_node_x = start_node_x
self.start_node_y = start_node_y
self.path = path
self.path_coords = path_coords
# For BFS and DFS mainly
def get_path_coords(self):
i = self.start_node_x
j = self.start_node_y
for move in self.path:
if move == 'L':
i -= 1
elif move == 'R':
i += 1
elif move == 'U':
j -= 1
elif move == 'D':
j += 1
self.path_coords.append((i,j))
def draw_path(self):
self.path_coords.pop()
for (x_pos, y_pos) in self.path_coords:
pygame.draw.rect(self.surface, SPRINGGREEN, (x_pos*24 + 240, y_pos*24, 24, 24), 0)