wybór punktu w A*
This commit is contained in:
parent
84e66ab30f
commit
6244a2832f
8
tiles.py
8
tiles.py
@ -344,7 +344,6 @@ def astar(map, start, end):
|
|||||||
continue
|
continue
|
||||||
open_list.append(child)
|
open_list.append(child)
|
||||||
|
|
||||||
|
|
||||||
map = Map()
|
map = Map()
|
||||||
waiter = Waiter([32, 32])
|
waiter = Waiter([32, 32])
|
||||||
tables = []
|
tables = []
|
||||||
@ -363,7 +362,6 @@ for i in range(16):
|
|||||||
for table in tables:
|
for table in tables:
|
||||||
map.add_table(table.loc)
|
map.add_table(table.loc)
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
direction = []
|
direction = []
|
||||||
while True:
|
while True:
|
||||||
@ -393,9 +391,11 @@ def main():
|
|||||||
left, middle, right = pygame.mouse.get_pressed()
|
left, middle, right = pygame.mouse.get_pressed()
|
||||||
if left:
|
if left:
|
||||||
waiterGo(mouseToNum())
|
waiterGo(mouseToNum())
|
||||||
|
|
||||||
elif right:
|
elif right:
|
||||||
goal = (18, 18)
|
x = pygame.mouse.get_pos()[1]
|
||||||
|
y = pygame.mouse.get_pos()[0]
|
||||||
|
goal = (x//32, y//32)
|
||||||
|
#goal = (18,18)
|
||||||
route = astar(map.get_arr(), (waiter.loc[1] // 32, waiter.loc[0] // 32), goal)
|
route = astar(map.get_arr(), (waiter.loc[1] // 32, waiter.loc[0] // 32), goal)
|
||||||
direction = [(x[1] - y[1], x[0] - y[0]) for x, y in zip(route[1:], route)]
|
direction = [(x[1] - y[1], x[0] - y[0]) for x, y in zip(route[1:], route)]
|
||||||
if len(direction) > 0:
|
if len(direction) > 0:
|
||||||
|
Loading…
Reference in New Issue
Block a user