2021-03-29 01:15:48 +02:00
|
|
|
from Main.drawUI import *
|
2021-03-28 22:42:36 +02:00
|
|
|
import pygame
|
|
|
|
|
|
|
|
def cruiseControl(cruiseControl, horizontal_change, vertical_change, tractor_horizontal_index, tractor_vertical_index):
|
|
|
|
if not cruiseControl:
|
|
|
|
horizontal_change = 0
|
|
|
|
vertical_change = 0
|
|
|
|
if tractor_horizontal_index < 1 or tractor_horizontal_index >= HORIZONTAL_TILES_NUMBER - 1:
|
|
|
|
horizontal_change = 0
|
|
|
|
if tractor_vertical_index < 1 or tractor_vertical_index >= VERTICAL_TILES_NUMBER - 1:
|
|
|
|
vertical_change = 0
|
|
|
|
return horizontal_change, vertical_change
|
|
|
|
|
|
|
|
|
|
|
|
def manualTurning(event, tractor_horizontal_index, tractor_vertical_index, horizontal_change=0, vertical_change=0):
|
|
|
|
if event.type == pygame.KEYDOWN:
|
|
|
|
if event.key == pygame.K_LEFT and tractor_horizontal_index > 0:
|
2021-03-28 22:55:01 +02:00
|
|
|
vertical_change = 0
|
2021-03-28 22:42:36 +02:00
|
|
|
horizontal_change = -1
|
2021-03-29 01:15:48 +02:00
|
|
|
|
2021-03-28 22:42:36 +02:00
|
|
|
elif event.key == pygame.K_RIGHT and tractor_horizontal_index < HORIZONTAL_TILES_NUMBER - 1:
|
|
|
|
horizontal_change = 1
|
2021-03-28 22:55:01 +02:00
|
|
|
vertical_change = 0
|
2021-03-28 22:42:36 +02:00
|
|
|
elif event.key == pygame.K_UP and tractor_vertical_index > 0:
|
|
|
|
vertical_change = -1
|
2021-03-28 22:55:01 +02:00
|
|
|
horizontal_change = 0
|
2021-03-28 22:42:36 +02:00
|
|
|
elif event.key == pygame.K_DOWN and tractor_vertical_index < VERTICAL_TILES_NUMBER - 1:
|
|
|
|
vertical_change = 1
|
2021-03-28 22:55:01 +02:00
|
|
|
horizontal_change = 0
|
2021-03-28 22:42:36 +02:00
|
|
|
|
|
|
|
return horizontal_change, vertical_change
|