naprawienie kolizji ze stołami i krzesłami
This commit is contained in:
parent
6244a2832f
commit
421b42d578
31
tiles.py
31
tiles.py
@ -362,6 +362,25 @@ for i in range(16):
|
||||
for table in tables:
|
||||
map.add_table(table.loc)
|
||||
|
||||
def check_collision_with_table(x,y):
|
||||
answer = False
|
||||
for i in tables_coordinates:
|
||||
if i[0] <= x <= i[0] + 32 and i[1] <= y <= i[1] + 32:
|
||||
answer = True
|
||||
else:
|
||||
continue
|
||||
return answer
|
||||
|
||||
def check_collision_with_chair(x,y):
|
||||
answer = False
|
||||
for i in chairs:
|
||||
for j in i:
|
||||
if j.loc[0] <= x <= j.loc[0] + 32 and j.loc[1] <= y <= j.loc[1] + 32:
|
||||
answer = True
|
||||
else:
|
||||
continue
|
||||
return answer
|
||||
|
||||
def main():
|
||||
direction = []
|
||||
while True:
|
||||
@ -392,10 +411,20 @@ def main():
|
||||
if left:
|
||||
waiterGo(mouseToNum())
|
||||
elif right:
|
||||
while True:
|
||||
x = pygame.mouse.get_pos()[1]
|
||||
y = pygame.mouse.get_pos()[0]
|
||||
if y > 608 or y < 32 or x > 608 or x < 32 or check_collision_with_table(y,x) or check_collision_with_chair(y, x):
|
||||
print("I can't go there")
|
||||
break
|
||||
goal = (x // 32, y // 32)
|
||||
#goal = (18,18)
|
||||
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)]
|
||||
break
|
||||
elif middle:
|
||||
x = pygame.mouse.get_pos()[1]
|
||||
y = pygame.mouse.get_pos()[0]
|
||||
goal = (18,18)
|
||||
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)]
|
||||
if len(direction) > 0:
|
||||
|
Loading…
Reference in New Issue
Block a user