From ba1f2d96b6cf8fa504a1925a28b9a8f284eb285c Mon Sep 17 00:00:00 2001 From: v7eZ3t Date: Sun, 28 Mar 2021 22:55:01 +0200 Subject: [PATCH] v. 1.06 --- drawUI.py | 4 ++++ driving.py | 4 ++++ main.py | 6 +++--- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/drawUI.py b/drawUI.py index 29cf0c3..128068e 100644 --- a/drawUI.py +++ b/drawUI.py @@ -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 diff --git a/driving.py b/driving.py index 4710aa4..f0d8c0a 100644 --- a/driving.py +++ b/driving.py @@ -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 diff --git a/main.py b/main.py index e628551..332414f 100644 --- a/main.py +++ b/main.py @@ -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,