From 55171b73f9194af5d3188449606c2b9022ceaafd Mon Sep 17 00:00:00 2001 From: secret_dude Date: Tue, 13 Apr 2021 18:48:24 +0200 Subject: [PATCH] SterowanieManualnePrzeniesione --- constants.py | 2 +- main.py | 2 -- manualSteering.py | 12 ++++++------ 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/constants.py b/constants.py index c5f70b9..3ca4a9f 100644 --- a/constants.py +++ b/constants.py @@ -29,7 +29,7 @@ TRACTOR_WIDTH = TILE_SIZE TRACTOR_HEIGHT = TILE_SIZE #FRAMES PER SECOND -FPS = 1 +FPS = 10 #ANIMATION_PART diff --git a/main.py b/main.py index 8ab98c7..0fb8bf8 100644 --- a/main.py +++ b/main.py @@ -50,8 +50,6 @@ while working: if tractor.engineWorking: tractor.reduce_fuel() - tractor.drive() - drawUI.drawUI(board, display, tractor, tractor.direction, tillageUnit, field, animationSpeed) clock.tick(FPS) diff --git a/manualSteering.py b/manualSteering.py index 3208b91..c5db30a 100644 --- a/manualSteering.py +++ b/manualSteering.py @@ -1,8 +1,8 @@ -import driving from constants import * from TractorAction import action import pygame + def manualSteeringDriver(event, board, tractor, hitchCounter, tillageUnit, loadCounter, animationSpeed): if event.key == pygame.K_SPACE: field = board[tractor.horizontal_index][tractor.vertical_index] @@ -30,6 +30,10 @@ def manualSteeringDriver(event, board, tractor, hitchCounter, tillageUnit, loadC tillageUnit.load = "Water" elif loadCounter == 3: tillageUnit.load = "Fertilizer" + + if event.key == pygame.K_SPACE: + tractor.drive() + if event.key == pygame.K_r: if tractor.engineWorking: tractor.turnOffEngine() @@ -49,6 +53,7 @@ def manualSteeringDriver(event, board, tractor, hitchCounter, tillageUnit, loadC manualTurning(event, tractor) return hitchCounter, loadCounter, animationSpeed + def manualTurning(event, tractor): tractor.direction = "STOP" if event.type == pygame.KEYDOWN: @@ -60,8 +65,3 @@ def manualTurning(event, tractor): tractor.direction = "UP" elif event.key == pygame.K_DOWN and tractor.vertical_index < VERTICAL_TILES_NUMBER - 1: tractor.direction = "DOWN" - - - - -