From b3da1c6654af6a9f52df66ead601a9276c2e4339 Mon Sep 17 00:00:00 2001 From: secret_dude Date: Tue, 13 Apr 2021 18:57:48 +0200 Subject: [PATCH] animations update --- animations.py | 7 +++++++ main.py | 12 ++++++++++-- manualSteering.py | 10 +++------- 3 files changed, 20 insertions(+), 9 deletions(-) create mode 100644 animations.py diff --git a/animations.py b/animations.py new file mode 100644 index 0000000..67fead2 --- /dev/null +++ b/animations.py @@ -0,0 +1,7 @@ +from constants import ANIMATION_PART + +def animationsOn(): + ANIMATION_PART = 11 + +def animationsOff(): + ANIMATION_PART = 1 \ No newline at end of file diff --git a/main.py b/main.py index 0fb8bf8..15c992c 100644 --- a/main.py +++ b/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) diff --git a/manualSteering.py b/manualSteering.py index c5db30a..740c27c 100644 --- a/manualSteering.py +++ b/manualSteering.py @@ -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):