This commit is contained in:
v7eZ3t 2021-03-28 22:55:01 +02:00
parent f72df6eac1
commit ba1f2d96b6
3 changed files with 11 additions and 3 deletions

View File

@ -1,9 +1,13 @@
from Main.constants import *
import pygame
def drawUI(board, display, tractor_horizontal_index, tractor_vertical_index):
display.fill(WHITE)
makeField(board, display)
drawTractor(display, tractor_horizontal_index, tractor_vertical_index)
pygame.display.update()
def makeField(board, display):
color = BLACK

View File

@ -16,12 +16,16 @@ def cruiseControl(cruiseControl, horizontal_change, vertical_change, tractor_hor
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:
vertical_change = 0
horizontal_change = -1
elif event.key == pygame.K_RIGHT and tractor_horizontal_index < HORIZONTAL_TILES_NUMBER - 1:
horizontal_change = 1
vertical_change = 0
elif event.key == pygame.K_UP and tractor_vertical_index > 0:
vertical_change = -1
horizontal_change = 0
elif event.key == pygame.K_DOWN and tractor_vertical_index < VERTICAL_TILES_NUMBER - 1:
vertical_change = 1
horizontal_change = 0
return horizontal_change, vertical_change

View File

@ -38,12 +38,12 @@ while working:
tractor_vertical_index, horizontal_change,
vertical_change)
tractor_horizontal_index += horizontal_change
tractor_vertical_index += vertical_change
display.fill(WHITE)
drawUI.drawUI(board, display, tractor_horizontal_index, tractor_vertical_index)
pygame.display.update()
clock.tick(FPS)
horizontal_change, vertical_change = driving.cruiseControl(cruiseControl, horizontal_change, vertical_change,