forked from s452751/AI_PRO
v. 1.06
This commit is contained in:
parent
f72df6eac1
commit
ba1f2d96b6
@ -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
|
||||
|
@ -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
|
||||
|
6
main.py
6
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,
|
||||
|
Loading…
Reference in New Issue
Block a user