diff --git a/blocks.py b/blocks.py index 759e568b..7dfa349f 100644 --- a/blocks.py +++ b/blocks.py @@ -1,6 +1,8 @@ import pygame import random from pygame.math import Vector2 +import soil + class Blocks: def __init__(self, parent_screen,cell_size): @@ -17,6 +19,8 @@ class Blocks: self.alive_leaf_image = pygame.image.load(r'resources/alive.png').convert_alpha() self.alive_leaf_image = pygame.transform.scale(self.alive_leaf_image, (cell_size, cell_size)) + self.soil = soil.Soil() + def locate_blocks(self, blocks_number, cell_number, body): for i in range(blocks_number): @@ -40,9 +44,25 @@ class Blocks: self.parent_screen.blit(self.stone_image, (x, y)) if color == 'flower': self.parent_screen.blit(self.flower_image, (x, y)) - + + # if color == 'potato': + # pass + + def locate_soil(self, name, acidity, irrigation, blocks_number): + # for block in blocks_number: + self.soil.set_name(name) + self.soil.set_irrigation(irrigation) + self.soil.set_acidity(acidity) + + def get_soil_info(self): + return self.soil def draw_lines(self, parent_screen, cell_size): # background lines for i in range(1, 10): pygame.draw.line(self.parent_screen, (228, 253, 227), (cell_size * i, 0), (cell_size * i, parent_screen), 1) pygame.draw.line(self.parent_screen, (228, 253, 227), (0, cell_size * i), (parent_screen, cell_size * i), 1) + + + + + diff --git a/land.py b/land.py index bbed151e..89f6bf0a 100644 --- a/land.py +++ b/land.py @@ -19,7 +19,7 @@ class Land: x = int(body[0] * cell_size) y = int(body[1] * cell_size) if(name == 'good'): - parent_screen.blit(self.grass_image, (x, y)) + parent_screen.blit(self.grass_image, (x, y)) # to-check: () redundant parentheses if(name == 'bad'): parent_screen.blit(self.bad_grass_image, (x, y)) \ No newline at end of file diff --git a/main.py b/main.py index fba8d115..efed0767 100644 --- a/main.py +++ b/main.py @@ -1,3 +1,5 @@ +import os + import pygame import random import land @@ -10,7 +12,7 @@ from datetime import datetime class Game: cell_size = 50 cell_number = 15 #horizontally - blocks_number = 15 + blocks_number = 15 # to-check sth is wrong: duplicate(?) and overlap def __init__(self): self.dead_leaf_body = [] @@ -20,7 +22,9 @@ class Game: self.dead_grass_body = [] self.grass_body = [] - + self.potato_field = [] + + self.entire_block = {} pygame.init() @@ -34,10 +38,16 @@ class Game: self.blocks.locate_blocks(self.blocks_number, self.cell_number, self.stone_body) self.blocks.locate_blocks(self.blocks_number, self.cell_number, self.flower_body) + self.potato = blocks.Blocks(self.surface, self.cell_size) + self.potato.locate_soil('black earth', 6, 1, []) + self.tractor = tractor.Tractor(self.surface, self.cell_size) self.tractor.draw() def run(self): + print(self.potato.get_soil_info().get_name()) + print(self.potato.get_soil_info().get_acidity()) + print(self.potato.get_soil_info().get_irrigation()) running = True clock = pygame.time.Clock() last_time = datetime.now() diff --git a/soil.py b/soil.py new file mode 100644 index 00000000..5737de54 --- /dev/null +++ b/soil.py @@ -0,0 +1,23 @@ +class Soil: + def __init__(self, name='', irrigation=-1, acidity=-1): + self._name = name + self._irrigation = irrigation + self._acidity = acidity + + def get_name(self): + return self._name + + def set_name(self, name): + self._name = name + + def get_acidity(self): + return self._acidity + + def set_acidity(self, acidity): + self._acidity = acidity + + def get_irrigation(self): + return self._irrigation + + def set_irrigation(self, irrigation): + self._irrigation = irrigation diff --git a/tractor.py b/tractor.py index 58d9678e..aaab31a4 100644 --- a/tractor.py +++ b/tractor.py @@ -15,7 +15,7 @@ class Tractor: self.left = pygame.transform.scale(self.left, (cell_size+2, cell_size+2)) self.right = pygame.transform.scale(self.right, (cell_size+4, cell_size+1)) - self.x = cell_size*2 + self.x = cell_size*2 # to-check: start pos may be written explicit self.y = cell_size*2 #self.pos = Vector2(self.x, self.y) self.angle = 0