SterowanieManualnePrzeniesione
This commit is contained in:
parent
ac55e5bf57
commit
55171b73f9
@ -29,7 +29,7 @@ TRACTOR_WIDTH = TILE_SIZE
|
|||||||
TRACTOR_HEIGHT = TILE_SIZE
|
TRACTOR_HEIGHT = TILE_SIZE
|
||||||
|
|
||||||
#FRAMES PER SECOND
|
#FRAMES PER SECOND
|
||||||
FPS = 1
|
FPS = 10
|
||||||
|
|
||||||
#ANIMATION_PART
|
#ANIMATION_PART
|
||||||
|
|
||||||
|
2
main.py
2
main.py
@ -50,8 +50,6 @@ while working:
|
|||||||
if tractor.engineWorking:
|
if tractor.engineWorking:
|
||||||
tractor.reduce_fuel()
|
tractor.reduce_fuel()
|
||||||
|
|
||||||
tractor.drive()
|
|
||||||
|
|
||||||
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)
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import driving
|
|
||||||
from constants import *
|
from constants import *
|
||||||
from TractorAction import action
|
from TractorAction import action
|
||||||
import pygame
|
import pygame
|
||||||
|
|
||||||
|
|
||||||
def manualSteeringDriver(event, board, tractor, hitchCounter, tillageUnit, loadCounter, animationSpeed):
|
def manualSteeringDriver(event, board, tractor, hitchCounter, tillageUnit, loadCounter, animationSpeed):
|
||||||
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]
|
||||||
@ -30,6 +30,10 @@ def manualSteeringDriver(event, board, tractor, hitchCounter, tillageUnit, loadC
|
|||||||
tillageUnit.load = "Water"
|
tillageUnit.load = "Water"
|
||||||
elif loadCounter == 3:
|
elif loadCounter == 3:
|
||||||
tillageUnit.load = "Fertilizer"
|
tillageUnit.load = "Fertilizer"
|
||||||
|
|
||||||
|
if event.key == pygame.K_SPACE:
|
||||||
|
tractor.drive()
|
||||||
|
|
||||||
if event.key == pygame.K_r:
|
if event.key == pygame.K_r:
|
||||||
if tractor.engineWorking:
|
if tractor.engineWorking:
|
||||||
tractor.turnOffEngine()
|
tractor.turnOffEngine()
|
||||||
@ -49,6 +53,7 @@ def manualSteeringDriver(event, board, tractor, hitchCounter, tillageUnit, loadC
|
|||||||
manualTurning(event, tractor)
|
manualTurning(event, tractor)
|
||||||
return hitchCounter, loadCounter, animationSpeed
|
return hitchCounter, loadCounter, animationSpeed
|
||||||
|
|
||||||
|
|
||||||
def manualTurning(event, tractor):
|
def manualTurning(event, tractor):
|
||||||
tractor.direction = "STOP"
|
tractor.direction = "STOP"
|
||||||
if event.type == pygame.KEYDOWN:
|
if event.type == pygame.KEYDOWN:
|
||||||
@ -60,8 +65,3 @@ def manualTurning(event, tractor):
|
|||||||
tractor.direction = "UP"
|
tractor.direction = "UP"
|
||||||
elif event.key == pygame.K_DOWN and tractor.vertical_index < VERTICAL_TILES_NUMBER - 1:
|
elif event.key == pygame.K_DOWN and tractor.vertical_index < VERTICAL_TILES_NUMBER - 1:
|
||||||
tractor.direction = "DOWN"
|
tractor.direction = "DOWN"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user