minor updates
This commit is contained in:
parent
b3da1c6654
commit
84857e357c
@ -110,3 +110,4 @@ class Tractor:
|
|||||||
self.__horizontal_index += mRange
|
self.__horizontal_index += mRange
|
||||||
elif self.__direction == "LEFT" and self.horizontal_index > 0:
|
elif self.__direction == "LEFT" and self.horizontal_index > 0:
|
||||||
self.__horizontal_index += -mRange
|
self.__horizontal_index += -mRange
|
||||||
|
self.reduce_fuel()
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
from TractorLoad import TillageUnit
|
from TractorLoad import TillageUnit
|
||||||
|
|
||||||
|
|
||||||
def action(field, tractor):
|
def changeFieldState(field, tractor):
|
||||||
if tractor.header and tractor.hitch == "Crop Trailer" and field.state == "toCut":
|
if tractor.header and tractor.hitch == "Crop Trailer" and field.state == "toCut":
|
||||||
return "toPlow"
|
return "toPlow"
|
||||||
|
|
||||||
@ -18,7 +18,7 @@ def action(field, tractor):
|
|||||||
return "toCut"
|
return "toCut"
|
||||||
|
|
||||||
|
|
||||||
def autoAction(tractor, tillageUnit, toolCounter):
|
def autoToolsChange(tractor, tillageUnit, toolCounter):
|
||||||
if tractor.horizontal_index == 0 and tractor.vertical_index == 0:
|
if tractor.horizontal_index == 0 and tractor.vertical_index == 0:
|
||||||
toolCounter = (toolCounter + 1) % 5
|
toolCounter = (toolCounter + 1) % 5
|
||||||
tractor, tillageUnit = chooseToolset(tractor, tillageUnit, toolCounter)
|
tractor, tillageUnit = chooseToolset(tractor, tillageUnit, toolCounter)
|
||||||
|
20
main.py
20
main.py
@ -4,7 +4,6 @@ import Board
|
|||||||
import TractorAction
|
import TractorAction
|
||||||
import drawUI
|
import drawUI
|
||||||
from Tractor import Tractor
|
from Tractor import Tractor
|
||||||
from TractorAction import action
|
|
||||||
from TractorLoad import TillageUnit
|
from TractorLoad import TillageUnit
|
||||||
from animations import animationsOn, animationsOff
|
from animations import animationsOn, animationsOff
|
||||||
from constants import *
|
from constants import *
|
||||||
@ -20,7 +19,6 @@ autoAction = True
|
|||||||
|
|
||||||
animationSpeed = ANIMATION_PART
|
animationSpeed = ANIMATION_PART
|
||||||
|
|
||||||
|
|
||||||
hitchCounter = 0
|
hitchCounter = 0
|
||||||
loadCounter = 0
|
loadCounter = 0
|
||||||
toolCounter = - 1
|
toolCounter = - 1
|
||||||
@ -45,23 +43,19 @@ while working:
|
|||||||
|
|
||||||
field = board[tractor.horizontal_index][tractor.vertical_index]
|
field = board[tractor.horizontal_index][tractor.vertical_index]
|
||||||
|
|
||||||
if tractor.autodrive:
|
if tractor.autodrive and tractor.engineWorking:
|
||||||
animationsOn()
|
animationSpeed = 11
|
||||||
else:
|
else:
|
||||||
animationsOff()
|
animationSpeed = 1
|
||||||
|
print(ANIMATION_PART)
|
||||||
|
|
||||||
|
if tractor.autodrive:
|
||||||
|
tractor, tillageUnit, toolCounter = TractorAction.autoToolsChange(tractor, tillageUnit, toolCounter)
|
||||||
if autoAction:
|
field.state = TractorAction.changeFieldState(field, tractor)
|
||||||
tractor, tillageUnit, toolCounter = TractorAction.autoAction(tractor, tillageUnit, toolCounter)
|
|
||||||
field.state = action(field, tractor)
|
|
||||||
if tractor.engineWorking:
|
|
||||||
tractor.reduce_fuel()
|
|
||||||
|
|
||||||
drawUI.drawUI(board, display, tractor, tractor.direction, tillageUnit, field, animationSpeed)
|
drawUI.drawUI(board, display, tractor, tractor.direction, tillageUnit, field, animationSpeed)
|
||||||
|
|
||||||
clock.tick(FPS)
|
clock.tick(FPS)
|
||||||
|
|
||||||
|
|
||||||
pygame.quit()
|
pygame.quit()
|
||||||
quit()
|
quit()
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
|
from TractorAction import changeFieldState
|
||||||
from constants import *
|
from constants import *
|
||||||
from TractorAction import action
|
|
||||||
import pygame
|
import pygame
|
||||||
|
|
||||||
|
|
||||||
def manualSteeringDriver(event, board, tractor, hitchCounter, tillageUnit, loadCounter):
|
def manualSteeringDriver(event, board, tractor, hitchCounter, tillageUnit, loadCounter):
|
||||||
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]
|
||||||
field.state = action(field, tractor)
|
field.state = changeFieldState(field, tractor)
|
||||||
if event.key == pygame.K_q:
|
if event.key == pygame.K_q:
|
||||||
hitchCounter = (hitchCounter + 1) % 3
|
hitchCounter = (hitchCounter + 1) % 3
|
||||||
if hitchCounter == 0:
|
if hitchCounter == 0:
|
||||||
|
Loading…
Reference in New Issue
Block a user