import sys import secrets from src.graphics import * from src.waiter import * if __name__ == "__main__": # SETUP pygame.init() clock = pygame.time.Clock() fps = 2 graphics = Graphics() waiter = Waiter(graphics) # init functions graphics.drawBackground(waiter.matrix) graphics.update(waiter.X, waiter.Y) goal = None path = [(0, 0)] # print(waiter.findPath()) while True: for event in pygame.event.get(): if event.type == pygame.QUIT: pygame.quit() sys.exit() break if event.type == pygame.KEYDOWN: if event.key == pygame.K_ESCAPE: pygame.quit() sys.exit() break if event.key == pygame.K_r: temp = False while not temp: x = secrets.randbelow(graphics.width) y = secrets.randbelow(graphics.height) if waiter.matrix.matrix[x][y].walk_through == 1: temp = True goal = (x, y) path = waiter.findPath(goal) print('goal: {}'.format(goal)) if path != []: print(path) nextStep = path.pop(0) print(nextStep) waiter.travel(nextStep, graphics) print('{} {} current position'.format(waiter.X, waiter.Y)) ''' graphics.clear(waiter.X, waiter.Y) waiter.update(event, graphics) graphics.update(waiter.X, waiter.Y) ''' pygame.display.flip() clock.tick(fps)