2021-03-17 00:57:06 +01:00
|
|
|
import pygame
|
2021-03-17 01:54:26 +01:00
|
|
|
# wersja 1.05
|
2021-03-17 00:57:06 +01:00
|
|
|
|
2021-03-28 22:42:36 +02:00
|
|
|
from Main import Board, driving, drawUI
|
2021-03-28 23:18:29 +02:00
|
|
|
from Main.Tractor import Tractor
|
2021-03-17 00:57:06 +01:00
|
|
|
from Main.constants import *
|
|
|
|
|
|
|
|
pygame.init()
|
|
|
|
|
|
|
|
display = pygame.display.set_mode((DISPLAY_SIZE_HORIZONTAL, DISPLAY_SIZE_VERTICAL))
|
2021-03-17 14:48:50 +01:00
|
|
|
pygame.display.set_caption('Tractor')
|
2021-03-17 00:57:06 +01:00
|
|
|
|
2021-03-17 01:02:20 +01:00
|
|
|
working = True
|
2021-03-28 22:42:36 +02:00
|
|
|
cruiseControl = True
|
2021-03-17 00:57:06 +01:00
|
|
|
|
|
|
|
horizontal_change = 0
|
|
|
|
vertical_change = 0
|
|
|
|
|
|
|
|
board = Board.generate()
|
|
|
|
|
2021-03-29 00:40:43 +02:00
|
|
|
tractor = Tractor(horizontal_index=0, vertical_index=0, hitch="nothing", header=False, fuel_tank=100)
|
2021-03-28 23:18:29 +02:00
|
|
|
|
|
|
|
clock = pygame.time.Clock()
|
2021-03-28 22:42:36 +02:00
|
|
|
|
2021-03-17 01:02:20 +01:00
|
|
|
while working:
|
2021-03-17 00:57:06 +01:00
|
|
|
for event in pygame.event.get():
|
|
|
|
if event.type == pygame.QUIT:
|
2021-03-17 01:02:20 +01:00
|
|
|
working = False
|
2021-03-17 00:57:06 +01:00
|
|
|
if event.type == pygame.KEYDOWN:
|
2021-03-28 22:42:36 +02:00
|
|
|
if event.key == pygame.K_SPACE:
|
2021-03-28 23:18:29 +02:00
|
|
|
field = board[tractor.horizontal_index][tractor.vertical_index]
|
2021-03-28 22:42:36 +02:00
|
|
|
field.state = 4
|
2021-03-28 23:18:29 +02:00
|
|
|
horizontal_change, vertical_change = driving.manualTurning(event, tractor.horizontal_index,
|
|
|
|
tractor.vertical_index, horizontal_change,
|
2021-03-28 22:42:36 +02:00
|
|
|
vertical_change)
|
2021-03-28 23:18:29 +02:00
|
|
|
tractor.horizontal_index += horizontal_change
|
|
|
|
tractor.vertical_index += vertical_change
|
2021-03-28 22:55:01 +02:00
|
|
|
|
2021-03-28 23:18:29 +02:00
|
|
|
horizontal_change, vertical_change = driving.cruiseControl(cruiseControl, horizontal_change, vertical_change,
|
|
|
|
tractor.horizontal_index, tractor.vertical_index)
|
2021-03-17 00:57:06 +01:00
|
|
|
|
2021-03-28 23:18:29 +02:00
|
|
|
drawUI.drawUI(board, display, tractor.horizontal_index, tractor.vertical_index)
|
2021-03-28 22:55:01 +02:00
|
|
|
|
2021-03-17 00:57:06 +01:00
|
|
|
clock.tick(FPS)
|
2021-03-28 22:42:36 +02:00
|
|
|
|
2021-03-28 23:18:29 +02:00
|
|
|
print(tractor.horizontal_index + horizontal_change, " ", tractor.vertical_index + vertical_change)
|
2021-03-28 22:42:36 +02:00
|
|
|
print(horizontal_change, " ", vertical_change)
|
2021-03-17 00:57:06 +01:00
|
|
|
|
|
|
|
pygame.quit()
|
|
|
|
quit()
|