minor updates

This commit is contained in:
secret_dude 2021-04-13 20:29:06 +02:00
parent b3da1c6654
commit 84857e357c
4 changed files with 12 additions and 17 deletions

View File

@ -110,3 +110,4 @@ class Tractor:
self.__horizontal_index += mRange
elif self.__direction == "LEFT" and self.horizontal_index > 0:
self.__horizontal_index += -mRange
self.reduce_fuel()

View File

@ -1,7 +1,7 @@
from TractorLoad import TillageUnit
def action(field, tractor):
def changeFieldState(field, tractor):
if tractor.header and tractor.hitch == "Crop Trailer" and field.state == "toCut":
return "toPlow"
@ -18,7 +18,7 @@ def action(field, tractor):
return "toCut"
def autoAction(tractor, tillageUnit, toolCounter):
def autoToolsChange(tractor, tillageUnit, toolCounter):
if tractor.horizontal_index == 0 and tractor.vertical_index == 0:
toolCounter = (toolCounter + 1) % 5
tractor, tillageUnit = chooseToolset(tractor, tillageUnit, toolCounter)

20
main.py
View File

@ -4,7 +4,6 @@ import Board
import TractorAction
import drawUI
from Tractor import Tractor
from TractorAction import action
from TractorLoad import TillageUnit
from animations import animationsOn, animationsOff
from constants import *
@ -20,7 +19,6 @@ autoAction = True
animationSpeed = ANIMATION_PART
hitchCounter = 0
loadCounter = 0
toolCounter = - 1
@ -45,23 +43,19 @@ while working:
field = board[tractor.horizontal_index][tractor.vertical_index]
if tractor.autodrive:
animationsOn()
if tractor.autodrive and tractor.engineWorking:
animationSpeed = 11
else:
animationsOff()
animationSpeed = 1
print(ANIMATION_PART)
if autoAction:
tractor, tillageUnit, toolCounter = TractorAction.autoAction(tractor, tillageUnit, toolCounter)
field.state = action(field, tractor)
if tractor.engineWorking:
tractor.reduce_fuel()
if tractor.autodrive:
tractor, tillageUnit, toolCounter = TractorAction.autoToolsChange(tractor, tillageUnit, toolCounter)
field.state = TractorAction.changeFieldState(field, tractor)
drawUI.drawUI(board, display, tractor, tractor.direction, tillageUnit, field, animationSpeed)
clock.tick(FPS)
pygame.quit()
quit()

View File

@ -1,12 +1,12 @@
from TractorAction import changeFieldState
from constants import *
from TractorAction import action
import pygame
def manualSteeringDriver(event, board, tractor, hitchCounter, tillageUnit, loadCounter):
if event.key == pygame.K_SPACE:
field = board[tractor.horizontal_index][tractor.vertical_index]
field.state = action(field, tractor)
field.state = changeFieldState(field, tractor)
if event.key == pygame.K_q:
hitchCounter = (hitchCounter + 1) % 3
if hitchCounter == 0: