diff --git a/Tractor.py b/Tractor.py new file mode 100644 index 0000000..70d248a --- /dev/null +++ b/Tractor.py @@ -0,0 +1,4 @@ +class Tractor: + def __init__(self, horizontal_index, vertical_index): + self.horizontal_index = horizontal_index + self.vertical_index = vertical_index \ No newline at end of file diff --git a/main.py b/main.py index 332414f..d6e7dd5 100644 --- a/main.py +++ b/main.py @@ -2,14 +2,12 @@ import pygame # wersja 1.05 from Main import Board, driving, drawUI +from Main.Tractor import Tractor 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 @@ -18,13 +16,11 @@ 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 +tractor = Tractor(horizontal_index=0, vertical_index=0) + +clock = pygame.time.Clock() while working: for event in pygame.event.get(): @@ -32,24 +28,22 @@ while working: working = False if event.type == pygame.KEYDOWN: if event.key == pygame.K_SPACE: - field = board[tractor_horizontal_index][tractor_vertical_index] + 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, + 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 + 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) - + drawUI.drawUI(board, display, tractor.horizontal_index, tractor.vertical_index) 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(tractor.horizontal_index + horizontal_change, " ", tractor.vertical_index + vertical_change) print(horizontal_change, " ", vertical_change) pygame.quit()