This commit is contained in:
v7eZ3t 2021-03-29 13:46:30 +02:00
parent 9b75da63ac
commit 087cb6031d
2 changed files with 14 additions and 6 deletions

View File

@ -63,7 +63,7 @@ class Tractor:
@header.setter @header.setter
def header(self, header): def header(self, header):
if header is True or False: if header is True or header is False:
self.__header = header self.__header = header
@property @property

18
main.py
View File

@ -18,7 +18,7 @@ lastDirection = "RIGHT"
horizontal_change = 0 horizontal_change = 0
vertical_change = 0 vertical_change = 0
hitchCounter = 0
board = Board.generate() board = Board.generate()
tractor = Tractor(horizontal_index=0, vertical_index=0, hitch="nothing", header=False) tractor = Tractor(horizontal_index=0, vertical_index=0, hitch="nothing", header=False)
@ -33,13 +33,21 @@ while working:
if event.type == pygame.KEYDOWN: if event.type == pygame.KEYDOWN:
if event.key == pygame.K_SPACE: if event.key == pygame.K_SPACE:
field = board[tractor.horizontal_index][tractor.vertical_index] field = board[tractor.horizontal_index][tractor.vertical_index]
print(action(field, tractor))
field.state = action(field, tractor) field.state = action(field, tractor)
#print(field.state)
if event.key == pygame.K_q: if event.key == pygame.K_q:
tractor.hitch = "Crop Trailer" hitchCounter = (hitchCounter + 1) % 3
if hitchCounter == 0:
tractor.hitch = "Crop Trailer"
if hitchCounter == 1:
tractor.hitch = "Tillage Unit"
if hitchCounter == 2:
tractor.hitch = "Nothing"
if event.key == pygame.K_w: if event.key == pygame.K_w:
tractor.header = True if tractor.header:
tractor.header = False
else:
tractor.header = True
horizontal_change, vertical_change = driving.manualTurning(event, tractor.horizontal_index, horizontal_change, vertical_change = driving.manualTurning(event, tractor.horizontal_index,
tractor.vertical_index, horizontal_change, tractor.vertical_index, horizontal_change,
vertical_change) vertical_change)