63 lines
1.5 KiB
Python
63 lines
1.5 KiB
Python
import pygame
|
|
|
|
import Board
|
|
import TractorAction
|
|
import drawUI
|
|
from Tractor import Tractor
|
|
from TractorAction import action
|
|
from TractorLoad import TillageUnit
|
|
from constants import *
|
|
from manualSteering import manualSteeringDriver
|
|
|
|
# wersja 1.05
|
|
|
|
pygame.init()
|
|
|
|
display = pygame.display.set_mode((DISPLAY_SIZE_HORIZONTAL, DISPLAY_SIZE_VERTICAL))
|
|
pygame.display.set_caption('Tractor')
|
|
|
|
working = True
|
|
autoAction = True
|
|
|
|
animationSpeed = ANIMATION_PART
|
|
|
|
|
|
hitchCounter = 0
|
|
loadCounter = 0
|
|
toolCounter = - 1
|
|
|
|
board = Board.generate()
|
|
|
|
tractor = Tractor(horizontal_index=-0, vertical_index=0, hitch="nothing", header=False, autodrive=True,
|
|
direction='RIGHT')
|
|
tillageUnit = TillageUnit("Nothing")
|
|
|
|
tractor.turnOnEngine()
|
|
|
|
clock = pygame.time.Clock()
|
|
|
|
while working:
|
|
for event in pygame.event.get():
|
|
if event.type == pygame.QUIT:
|
|
working = False
|
|
if event.type == pygame.KEYDOWN:
|
|
hitchCounter, loadCounter, animationSpeed = \
|
|
manualSteeringDriver(event, board, tractor, hitchCounter, tillageUnit, loadCounter, animationSpeed)
|
|
|
|
field = board[tractor.horizontal_index][tractor.vertical_index]
|
|
|
|
if autoAction:
|
|
tractor, tillageUnit, toolCounter = TractorAction.autoAction(tractor, tillageUnit, toolCounter)
|
|
field.state = action(field, tractor)
|
|
|
|
tractor.drive()
|
|
|
|
drawUI.drawUI(board, display, tractor, tractor.direction, tillageUnit, field, animationSpeed)
|
|
|
|
clock.tick(FPS)
|
|
if tractor.engineWorking:
|
|
tractor.reduce_fuel()
|
|
|
|
pygame.quit()
|
|
quit()
|