animations update
This commit is contained in:
parent
55171b73f9
commit
b3da1c6654
7
animations.py
Normal file
7
animations.py
Normal file
@ -0,0 +1,7 @@
|
||||
from constants import ANIMATION_PART
|
||||
|
||||
def animationsOn():
|
||||
ANIMATION_PART = 11
|
||||
|
||||
def animationsOff():
|
||||
ANIMATION_PART = 1
|
12
main.py
12
main.py
@ -6,6 +6,7 @@ import drawUI
|
||||
from Tractor import Tractor
|
||||
from TractorAction import action
|
||||
from TractorLoad import TillageUnit
|
||||
from animations import animationsOn, animationsOff
|
||||
from constants import *
|
||||
from manualSteering import manualSteeringDriver
|
||||
|
||||
@ -39,11 +40,18 @@ while working:
|
||||
if event.type == pygame.QUIT:
|
||||
working = False
|
||||
if event.type == pygame.KEYDOWN:
|
||||
hitchCounter, loadCounter, animationSpeed = \
|
||||
manualSteeringDriver(event, board, tractor, hitchCounter, tillageUnit, loadCounter, animationSpeed)
|
||||
hitchCounter, loadCounter = \
|
||||
manualSteeringDriver(event, board, tractor, hitchCounter, tillageUnit, loadCounter)
|
||||
|
||||
field = board[tractor.horizontal_index][tractor.vertical_index]
|
||||
|
||||
if tractor.autodrive:
|
||||
animationsOn()
|
||||
else:
|
||||
animationsOff()
|
||||
|
||||
|
||||
|
||||
if autoAction:
|
||||
tractor, tillageUnit, toolCounter = TractorAction.autoAction(tractor, tillageUnit, toolCounter)
|
||||
field.state = action(field, tractor)
|
||||
|
@ -3,7 +3,7 @@ from TractorAction import action
|
||||
import pygame
|
||||
|
||||
|
||||
def manualSteeringDriver(event, board, tractor, hitchCounter, tillageUnit, loadCounter, animationSpeed):
|
||||
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)
|
||||
@ -31,27 +31,23 @@ def manualSteeringDriver(event, board, tractor, hitchCounter, tillageUnit, loadC
|
||||
elif loadCounter == 3:
|
||||
tillageUnit.load = "Fertilizer"
|
||||
|
||||
if event.key == pygame.K_SPACE:
|
||||
if event.key == pygame.K_m:
|
||||
tractor.drive()
|
||||
|
||||
if event.key == pygame.K_r:
|
||||
if tractor.engineWorking:
|
||||
tractor.turnOffEngine()
|
||||
animationSpeed = 1
|
||||
else:
|
||||
tractor.turnOnEngine()
|
||||
animationSpeed = ANIMATION_PART
|
||||
if event.key == pygame.K_t:
|
||||
if tractor.autodrive:
|
||||
tractor.autodrive = False
|
||||
animationSpeed = 1
|
||||
|
||||
else:
|
||||
tractor.autodrive = True
|
||||
animationSpeed = ANIMATION_PART
|
||||
|
||||
manualTurning(event, tractor)
|
||||
return hitchCounter, loadCounter, animationSpeed
|
||||
return hitchCounter, loadCounter
|
||||
|
||||
|
||||
def manualTurning(event, tractor):
|
||||
|
Loading…
Reference in New Issue
Block a user