Kontrola czy dane pole jest osiągalne - messagebox
This commit is contained in:
parent
86bd4e7973
commit
f0fa74f227
@ -3,6 +3,10 @@ import random
|
|||||||
import time
|
import time
|
||||||
import queue
|
import queue
|
||||||
import math
|
import math
|
||||||
|
from tkinter import messagebox
|
||||||
|
import tkinter as tk
|
||||||
|
root = tk.Tk()
|
||||||
|
root.withdraw() #ukrycie okna tworzonego przez tkinter
|
||||||
|
|
||||||
pygame.init()
|
pygame.init()
|
||||||
|
|
||||||
@ -350,6 +354,11 @@ class Waiter(object):
|
|||||||
def goByAStar(self, end):
|
def goByAStar(self, end):
|
||||||
positionList = aStar(self.pos, end)
|
positionList = aStar(self.pos, end)
|
||||||
print(positionList)
|
print(positionList)
|
||||||
|
if len(positionList) == 0:
|
||||||
|
messagebox.showerror("BŁĄD!", "Wybrano nieosiągalne pole!")
|
||||||
|
pygame.quit()
|
||||||
|
exit()
|
||||||
|
else:
|
||||||
lenght = len(positionList) - 1
|
lenght = len(positionList) - 1
|
||||||
for i in range(lenght):
|
for i in range(lenght):
|
||||||
movex = positionList[i + 1][0] - positionList[i][0]
|
movex = positionList[i + 1][0] - positionList[i][0]
|
||||||
@ -367,9 +376,6 @@ class Waiter(object):
|
|||||||
|
|
||||||
howToRotate = prevDirection - self.direction #działa!
|
howToRotate = prevDirection - self.direction #działa!
|
||||||
|
|
||||||
print(prevDirection)
|
|
||||||
print(self.direction)
|
|
||||||
print(howToRotate)
|
|
||||||
if howToRotate < 0:
|
if howToRotate < 0:
|
||||||
self.rotate = "left"
|
self.rotate = "left"
|
||||||
self.rotationNumber = abs(howToRotate)
|
self.rotationNumber = abs(howToRotate)
|
||||||
@ -380,13 +386,13 @@ class Waiter(object):
|
|||||||
self.rotate = "forward"
|
self.rotate = "forward"
|
||||||
self.rotationNumber = 0
|
self.rotationNumber = 0
|
||||||
|
|
||||||
print(self.rotate)
|
#print(self.rotate)
|
||||||
|
|
||||||
for i in range(self.rotationNumber):
|
for i in range(self.rotationNumber):
|
||||||
redrawWindow(window)
|
redrawWindow(window)
|
||||||
time.sleep(0.5)
|
time.sleep(0.5)
|
||||||
self.rotate = "forward"
|
self.rotate = "forward"
|
||||||
self.rotationNumber -= 0
|
self.rotationNumber = 0
|
||||||
|
|
||||||
self.goForward(movex, movey)
|
self.goForward(movex, movey)
|
||||||
redrawWindow(window)
|
redrawWindow(window)
|
||||||
@ -471,7 +477,7 @@ def main():
|
|||||||
clock.tick(60)
|
clock.tick(60)
|
||||||
redrawWindow(window)
|
redrawWindow(window)
|
||||||
#bot.moveRandomly()
|
#bot.moveRandomly()
|
||||||
goal = (1, 5)
|
goal = (1, 3)
|
||||||
bot.goByAStar(goal)
|
bot.goByAStar(goal)
|
||||||
time.sleep(60)
|
time.sleep(60)
|
||||||
flag = False
|
flag = False
|
||||||
|
Loading…
Reference in New Issue
Block a user