diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index e775232..6bb1ad4 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,7 +4,10 @@
+
+
+
@@ -86,6 +89,7 @@
+
@@ -93,22 +97,22 @@
-
+
-
-
+
+
-
-
+
+
-
-
+
+
-
+
@@ -125,12 +129,12 @@
-
+
-
+
-
+
\ No newline at end of file
diff --git a/__pycache__/plant.cpython-37.pyc b/__pycache__/plant.cpython-37.pyc
index 3e4e093..7acb7b4 100644
Binary files a/__pycache__/plant.cpython-37.pyc and b/__pycache__/plant.cpython-37.pyc differ
diff --git a/__pycache__/soil.cpython-37.pyc b/__pycache__/soil.cpython-37.pyc
index 36b18cd..9084cf8 100644
Binary files a/__pycache__/soil.cpython-37.pyc and b/__pycache__/soil.cpython-37.pyc differ
diff --git a/__pycache__/tractor.cpython-37.pyc b/__pycache__/tractor.cpython-37.pyc
index 160b8d0..ecec3a7 100644
Binary files a/__pycache__/tractor.cpython-37.pyc and b/__pycache__/tractor.cpython-37.pyc differ
diff --git a/definitions.py b/definitions.py
index bcde6b3..37d1b11 100644
--- a/definitions.py
+++ b/definitions.py
@@ -12,6 +12,7 @@ WIDTH, HEIGHT = 1000, 1000
WIN = pygame.display.set_mode((WIDTH, HEIGHT))
TRACTOR = pygame.image.load(os.path.join('resources', 'tractor.png'))
TRACTOR = pygame.transform.scale(TRACTOR, (BLOCK_SIZE, BLOCK_SIZE))
+TRACTOR_FERTILIZER = 2
WHEAT_GROW_TIME = 5
WHEAT_MAXIMUM_STATE = 21
WHEATSTAGE1 = pygame.image.load(os.path.join('resources', 'wheat_stage1.png'))
diff --git a/fertilizer.py b/fertilizer.py
new file mode 100644
index 0000000..488b8ee
--- /dev/null
+++ b/fertilizer.py
@@ -0,0 +1,7 @@
+class Fertilizer:
+ def __init__(self, name):
+ self.name = name
+ def get_name(self):
+ return self.name
+ def set_name(self, name):
+ self.name = name
\ No newline at end of file
diff --git a/plant.py b/plant.py
index d8c2d02..3f3f3b0 100644
--- a/plant.py
+++ b/plant.py
@@ -1,6 +1,11 @@
class Plant:
- def __init__(self, state):
+ def __init__(self, name, state):
+ self.name = name
self.state = state
+ def get_name(self):
+ return self.name
+ def set_name(self, name):
+ self.name = name
def get_state(self):
return self.state
def set_state(self, state):
diff --git a/py.py b/py.py
index bd17882..2137f68 100644
--- a/py.py
+++ b/py.py
@@ -12,8 +12,8 @@ def create_base_map():
temp_map_field = []
for j in range(10):
temp_rect = pygame.Rect(i * definitions.BLOCK_SIZE, j * definitions.BLOCK_SIZE, definitions.BLOCK_SIZE, definitions.BLOCK_SIZE)
- temp_soil = soil.Soil(False, False)
- temp_plant = plant.Plant(0)
+ temp_soil = soil.Soil(None, False, False)
+ temp_plant = plant.Plant("wheat", 0)
temp_field = field.Field(temp_plant, temp_rect, temp_soil)
temp_map_field.append(temp_field)
fields.append(temp_map_field)
@@ -22,15 +22,15 @@ def fill_map():
for j in range(10):
field = fields[i][j]
rect = field.get_rect()
- if field.get_plant().get_state() > 0 and field.get_plant().get_state() <= 1 * definitions.WHEAT_GROW_TIME:
+ if field.get_plant().get_name() == "wheat" and field.get_plant().get_state() > 0 and field.get_plant().get_state() <= 1 * definitions.WHEAT_GROW_TIME:
block = definitions.WHEATSTAGE1
- elif field.get_plant().get_state() > 1 * definitions.WHEAT_GROW_TIME and field.get_plant().get_state() <= 2 * definitions.WHEAT_GROW_TIME:
+ elif field.get_plant().get_name() == "wheat" and field.get_plant().get_state() > 1 * definitions.WHEAT_GROW_TIME and field.get_plant().get_state() <= 2 * definitions.WHEAT_GROW_TIME:
block = definitions.WHEATSTAGE2
- elif field.get_plant().get_state() > 2 * definitions.WHEAT_GROW_TIME and field.get_plant().get_state() <= 3 * definitions.WHEAT_GROW_TIME:
+ elif field.get_plant().get_name() == "wheat" and field.get_plant().get_state() > 2 * definitions.WHEAT_GROW_TIME and field.get_plant().get_state() <= 3 * definitions.WHEAT_GROW_TIME:
block = definitions.WHEATSTAGE3
- elif field.get_plant().get_state() > 3 * definitions.WHEAT_GROW_TIME and field.get_plant().get_state() <= 4 * definitions.WHEAT_GROW_TIME:
+ elif field.get_plant().get_name() == "wheat" and field.get_plant().get_state() > 3 * definitions.WHEAT_GROW_TIME and field.get_plant().get_state() <= 4 * definitions.WHEAT_GROW_TIME:
block = definitions.WHEATSTAGE4
- elif field.get_plant().get_state() == 4 *definitions.WHEAT_GROW_TIME + 1:
+ elif field.get_plant().get_name() == "wheat" and field.get_plant().get_state() == 4 *definitions.WHEAT_GROW_TIME + 1:
block = definitions.WHEATSTAGE5
elif field.get_soil().get_state() is False:
block = definitions.DIRT
@@ -48,8 +48,9 @@ def do_work(tractor1_rect):
elif field.get_soil().get_state() is True and field.get_soil().get_water_level() is False:
field.get_soil().set_water_level(True)
elif field.get_plant().get_state() == 0:
+ field.get_plant().set_name("wheat")
field.get_plant().set_state(1)
- elif field.get_plant().get_state() == definitions.WHEAT_MAXIMUM_STATE:
+ elif field.get_plant().get_name() == "wheat" and field.get_plant().get_state() == definitions.WHEAT_MAXIMUM_STATE:
field.get_plant().set_state(0)
field.get_soil().set_water_level(False)
field.get_soil().set_state(False)
@@ -61,7 +62,7 @@ def grow_plants():
for i in range(10):
for j in range(10):
field = fields[i][j]
- if field.get_plant().get_state() > 0 and field.get_plant().get_state() < definitions.WHEAT_MAXIMUM_STATE:
+ if field.get_plant().get_name() == "wheat" and field.get_plant().get_state() > 0 and field.get_plant().get_state() < definitions.WHEAT_MAXIMUM_STATE:
field.get_plant().set_state(field.get_plant().get_state() + 1)
def is_move_allowed(move, tractor1_rect):
if ((move == 1) and (tractor1_rect.y + definitions.BLOCK_SIZE + definitions.BLOCK_SIZE <= definitions.HEIGHT)):
@@ -100,7 +101,8 @@ def tractor1_handle_movement(tractor1, tractor1_rect):
loop = False
def main():
create_base_map()
- tractor1 = tractor.Tractor(0, 0)
+ fertilizer_dict = {"beetroot": definitions.TRACTOR_FERTILIZER, "carrot": definitions.TRACTOR_FERTILIZER, "potato": definitions.TRACTOR_FERTILIZER, "wheat": definitions.TRACTOR_FERTILIZER}
+ tractor1 = tractor.Tractor(fertilizer_dict, 0, 0)
tractor1_rect = pygame.Rect(tractor1.get_x(), tractor1.get_y(), definitions.BLOCK_SIZE, definitions.BLOCK_SIZE)
clock = pygame.time.Clock()
run = True
diff --git a/soil.py b/soil.py
index a383c4b..9d3c5eb 100644
--- a/soil.py
+++ b/soil.py
@@ -1,7 +1,12 @@
class Soil:
- def __init__(self, state, water_level):
+ def __init__(self, fertilizer, state, water_level):
+ self.fertilizer = fertilizer
self.state = state
self.water_level = water_level
+ def get_fertilizer(self):
+ return self.fertilizer
+ def set_fertilizer(self, fertilizer):
+ self.fertilizer = fertilizer
def get_state(self):
return self.state
def set_state(self, state):
diff --git a/tractor.py b/tractor.py
index a7df05f..14dc554 100644
--- a/tractor.py
+++ b/tractor.py
@@ -1,8 +1,13 @@
import definitions
class Tractor:
- def __init__(self, x, y):
+ def __init__(self, fertilizer, x, y):
+ self.fertilizer = fertilizer
self.x = x
self.y = y
+ def get_fertilizer(self):
+ return self.fertilizer
+ def set_fertilizer(self, fertilizer):
+ self.fertilizer = fertilizer
def get_x(self):
return self.x
def set_x(self, x):