import pygame # wersja 1.05 from Main import Board, driving, drawUI from Main.constants import * from Main.Field import Field pygame.init() # display size in pixels display = pygame.display.set_mode((DISPLAY_SIZE_HORIZONTAL, DISPLAY_SIZE_VERTICAL)) # program name pygame.display.set_caption('Tractor') working = True cruiseControl = True horizontal_change = 0 vertical_change = 0 change_tile = False board = Board.generate() color = BLACK clock = pygame.time.Clock() tractor_horizontal_index = 0 tractor_vertical_index = 0 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 display.fill(WHITE) drawUI.makeField(board, display) drawUI.drawTractor(board, display, tractor_horizontal_index, tractor_vertical_index) pygame.display.update() clock.tick(FPS) horizontal_change, vertical_change = driving.cruiseControl(cruiseControl, horizontal_change, vertical_change, tractor_horizontal_index, tractor_vertical_index) print(tractor_horizontal_index + horizontal_change, " ", tractor_vertical_index + vertical_change) print(horizontal_change, " ", vertical_change) pygame.quit() quit()