68 lines
1.8 KiB
Python
68 lines
1.8 KiB
Python
import pygame
|
|
|
|
import Board
|
|
import TractorAction
|
|
import drawUI
|
|
from FindPath import graphsearch
|
|
from Tractor import Tractor
|
|
from TractorLoad import TillageUnit
|
|
from animations import animationsOn, animationsOff
|
|
from constants import *
|
|
from manualSteering import manualSteeringDriver
|
|
from queue import Queue
|
|
|
|
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=False,
|
|
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 = \
|
|
manualSteeringDriver(event, board, tractor, hitchCounter, tillageUnit, loadCounter)
|
|
|
|
field = board[tractor.horizontal_index][tractor.vertical_index]
|
|
|
|
print("curr field cost", field.cost)
|
|
print("tractor dir", tractor.direction)
|
|
if tractor.autodrive and tractor.engineWorking:
|
|
animationSpeed = ANIMATION_PART
|
|
else:
|
|
animationSpeed = 1
|
|
print(ANIMATION_PART)
|
|
|
|
if tractor.autodrive:
|
|
tractor, tillageUnit, toolCounter = TractorAction.autoToolsChange(tractor, tillageUnit, toolCounter)
|
|
field.state = TractorAction.changeFieldState(field, tractor)
|
|
|
|
drawUI.drawUI(board, display, tractor, tractor.direction, tillageUnit, field, animationSpeed)
|
|
|
|
clock.tick(FPS)
|
|
|
|
#graphsearch(tractor, board, TillageUnit, Queue(), list())
|
|
|
|
pygame.quit()
|
|
quit()
|