From d778014e929e707f7d211be49dc8c5b67ab55d07 Mon Sep 17 00:00:00 2001 From: v7eZ3t Date: Mon, 29 Mar 2021 00:40:43 +0200 Subject: [PATCH] v. 1.06 --- Field.py | 16 ++++++++++++---- Tractor.py | 40 ++++++++++++++++++++++++++++++++++++++++ constants.py | 4 +--- drawUI.py | 10 +++++----- main.py | 2 +- 5 files changed, 59 insertions(+), 13 deletions(-) diff --git a/Field.py b/Field.py index 78a9fcd..4162935 100644 --- a/Field.py +++ b/Field.py @@ -1,5 +1,13 @@ class Field: - def __init__(self, horizontal, vertical, state): - self.horizontal = horizontal - self.vertical = vertical - self.state = state \ No newline at end of file + def __init__(self, __horizontal, __vertical, __state): + self.horizontal = __horizontal + self.vertical = __vertical + self.__state = __state + + @property + def state(self): + return self.__state + + @state.setter + def state(self, state): + self.__state = state diff --git a/Tractor.py b/Tractor.py index 4f5166f..fecf20d 100644 --- a/Tractor.py +++ b/Tractor.py @@ -5,3 +5,43 @@ class Tractor: self.hitch = hitch self.header = header self.fuel_tank = fuel_tank + + @property + def horizontal_index(self): + return self.__horizontal_index + + @horizontal_index.setter + def horizontal_index(self, horizontal_index): + self.__horizontal_index = horizontal_index + + @property + def vertical_index(self): + return self.__vertical_index + + @vertical_index.setter + def vertical_index(self, vertical_index): + self.__vertical_index = vertical_index + + @property + def hitch(self): + return self.__hitch + + @hitch.setter + def hitch(self, hitch): + self.__hitch = hitch + + @property + def fuel_tank(self): + return self.__fuel_tank + + @fuel_tank.setter + def fuel_tank(self, fuel_tank): + self.__fuel_tank = fuel_tank + + @property + def header(self): + return self.__header + + @header.setter + def header(self, header): + self.__header = header \ No newline at end of file diff --git a/constants.py b/constants.py index a09d46c..c78d8dc 100644 --- a/constants.py +++ b/constants.py @@ -5,7 +5,7 @@ DISPLAY_SIZE_HORIZONTAL = 600 DISPLAY_SIZE_VERTICAL = 600 #TILE DIVIDER = TILE SIZE -TILE_SIZE = 50 +TILE_SIZE = 30 # number of tiles HORIZONTAL_TILES_NUMBER = DISPLAY_SIZE_HORIZONTAL/TILE_SIZE @@ -22,8 +22,6 @@ GREEN = (0, 255, 0) #DO SCIECIA #tractor const -TRACTOR_HORIZONTAL_LOCATION = DISPLAY_SIZE_HORIZONTAL/2 -TRACTOR_VERTICAL_LOCATION = DISPLAY_SIZE_VERTICAL/2 TRACTOR_WIDTH = TILE_SIZE TRACTOR_HEIGHT = TILE_SIZE diff --git a/drawUI.py b/drawUI.py index 128068e..a53f394 100644 --- a/drawUI.py +++ b/drawUI.py @@ -15,15 +15,15 @@ def makeField(board, display): for j in range(int(VERTICAL_TILES_NUMBER)): field = board[i][j] - if field.state == 0: + if field.get_state() == 0: color = WHITE - elif field.state == 1: + elif field.get_state() == 1: color = RED - elif field.state == 2: + elif field.get_state() == 2: color = YELLOW - elif field.state == 3: + elif field.get_state() == 3: color = GREEN - elif field.state == 4: + elif field.get_state() == 4: color = BLACK pygame.draw.rect(display, color, [i * TILE_SIZE, j * TILE_SIZE, TILE_SIZE, TILE_SIZE]) diff --git a/main.py b/main.py index e3e6687..232cfaa 100644 --- a/main.py +++ b/main.py @@ -18,7 +18,7 @@ vertical_change = 0 board = Board.generate() -tractor = Tractor(horizontal_index=0, vertical_index=0, hitch="nothing", header="none", fuel_tank=100) +tractor = Tractor(horizontal_index=0, vertical_index=0, hitch="nothing", header=False, fuel_tank=100) clock = pygame.time.Clock()