from Main.drawUI import * import pygame def cruiseControl(tractor, direction, cruiseControl): if cruiseControl == False or tractor.engineWorking == False: direction = "STOP" return direction def manualTurning(event, tractor): direction = "NONE" if event.type == pygame.KEYDOWN: if event.key == pygame.K_LEFT and tractor.horizontal_index > 0: direction = "LEFT" elif event.key == pygame.K_RIGHT and tractor.horizontal_index < HORIZONTAL_TILES_NUMBER - 1: direction = "RIGHT" elif event.key == pygame.K_UP and tractor.vertical_index > 0: direction = "UP" elif event.key == pygame.K_DOWN and tractor.vertical_index < VERTICAL_TILES_NUMBER - 1: direction = "DOWN" tractor.turn(direction) return direction def getDirection(horizontal_change, vertical_change): direction = "STOP" if vertical_change == -1: direction = "UP" elif vertical_change == 1: direction = "DOWN" elif horizontal_change == 1: direction = "RIGHT" elif horizontal_change == -1: direction = "LEFT" return direction