51 lines
1.7 KiB
Python
51 lines
1.7 KiB
Python
import pygame
|
|
# wersja 1.05
|
|
|
|
from Main import Board, driving, drawUI
|
|
from Main.Tractor import Tractor
|
|
from Main.constants import *
|
|
|
|
pygame.init()
|
|
|
|
display = pygame.display.set_mode((DISPLAY_SIZE_HORIZONTAL, DISPLAY_SIZE_VERTICAL))
|
|
pygame.display.set_caption('Tractor')
|
|
|
|
working = True
|
|
cruiseControl = True
|
|
|
|
horizontal_change = 0
|
|
vertical_change = 0
|
|
|
|
board = Board.generate()
|
|
|
|
tractor = Tractor(horizontal_index=0, vertical_index=0, hitch="nothing", header=False, fuel_tank=100)
|
|
|
|
clock = pygame.time.Clock()
|
|
|
|
while working:
|
|
for event in pygame.event.get():
|
|
if event.type == pygame.QUIT:
|
|
working = False
|
|
if event.type == pygame.KEYDOWN:
|
|
if event.key == pygame.K_SPACE:
|
|
field = board[tractor.horizontal_index][tractor.vertical_index]
|
|
field.state = 4
|
|
horizontal_change, vertical_change = driving.manualTurning(event, tractor.horizontal_index,
|
|
tractor.vertical_index, horizontal_change,
|
|
vertical_change)
|
|
tractor.horizontal_index += horizontal_change
|
|
tractor.vertical_index += vertical_change
|
|
|
|
horizontal_change, vertical_change = driving.cruiseControl(cruiseControl, horizontal_change, vertical_change,
|
|
tractor.horizontal_index, tractor.vertical_index)
|
|
|
|
drawUI.drawUI(board, display, tractor.horizontal_index, tractor.vertical_index)
|
|
|
|
clock.tick(FPS)
|
|
|
|
print(tractor.horizontal_index + horizontal_change, " ", tractor.vertical_index + vertical_change)
|
|
print(horizontal_change, " ", vertical_change)
|
|
|
|
pygame.quit()
|
|
quit()
|