diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index a82677f..4904263 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,8 +4,9 @@
+
-
+
@@ -83,6 +84,8 @@
+
+
@@ -90,22 +93,22 @@
-
+
-
-
+
+
-
-
+
+
-
-
+
+
-
+
@@ -122,12 +125,12 @@
-
+
-
+
-
+
\ No newline at end of file
diff --git a/__pycache__/definitions.cpython-37.pyc b/__pycache__/definitions.cpython-37.pyc
index d82fe38..6db6b62 100644
Binary files a/__pycache__/definitions.cpython-37.pyc and b/__pycache__/definitions.cpython-37.pyc differ
diff --git a/__pycache__/plant.cpython-37.pyc b/__pycache__/plant.cpython-37.pyc
index 5118d99..45b67d5 100644
Binary files a/__pycache__/plant.cpython-37.pyc and b/__pycache__/plant.cpython-37.pyc differ
diff --git a/__pycache__/tractor.cpython-37.pyc b/__pycache__/tractor.cpython-37.pyc
index 11981dc..9133522 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 3e6b35a..e41bda1 100644
--- a/definitions.py
+++ b/definitions.py
@@ -12,5 +12,15 @@ 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))
-VEL = 100
-WHEAT_MAXIMUM_STATE = 5
\ No newline at end of file
+WHEAT_GROW_TIME = 5
+WHEAT_MAXIMUM_STATE = 22
+WHEATSTAGE1 = pygame.image.load(os.path.join('resources', 'wheat_stage1.png'))
+WHEATSTAGE1 = pygame.transform.scale(WHEATSTAGE1, (BLOCK_SIZE, BLOCK_SIZE))
+WHEATSTAGE2 = pygame.image.load(os.path.join('resources', 'wheat_stage2.png'))
+WHEATSTAGE2 = pygame.transform.scale(WHEATSTAGE2, (BLOCK_SIZE, BLOCK_SIZE))
+WHEATSTAGE3 = pygame.image.load(os.path.join('resources', 'wheat_stage3.png'))
+WHEATSTAGE3 = pygame.transform.scale(WHEATSTAGE3, (BLOCK_SIZE, BLOCK_SIZE))
+WHEATSTAGE4 = pygame.image.load(os.path.join('resources', 'wheat_stage4.png'))
+WHEATSTAGE4 = pygame.transform.scale(WHEATSTAGE4, (BLOCK_SIZE, BLOCK_SIZE))
+WHEATSTAGE5 = pygame.image.load(os.path.join('resources', 'wheat_stage5.png'))
+WHEATSTAGE5 = pygame.transform.scale(WHEATSTAGE5, (BLOCK_SIZE, BLOCK_SIZE))
\ No newline at end of file
diff --git a/plant.py b/plant.py
index 73bc7c5..d8c2d02 100644
--- a/plant.py
+++ b/plant.py
@@ -1,12 +1,7 @@
class Plant:
- def __init__(self, current_state, maximum_state):
- self.current_state = current_state
- self.maximum_state = maximum_state
- def get_current_state(self):
- return self.current_state
- def set_current_state(self, current_state):
- self.current_state = current_state
- def get_maximum_state(self):
- return self.maximum_state
- def set_maximum_state(self, maximum_state):
- self.maximum_state = maximum_state
\ No newline at end of file
+ def __init__(self, state):
+ self.state = state
+ def get_state(self):
+ return self.state
+ def set_state(self, state):
+ self.state = state
\ No newline at end of file
diff --git a/py.py b/py.py
index 3879fc8..28a6fec 100644
--- a/py.py
+++ b/py.py
@@ -13,7 +13,7 @@ def create_base_map():
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, definitions.WHEAT_MAXIMUM_STATE)
+ temp_plant = plant.Plant(0)
temp_field = field.Field(temp_plant, temp_rect, temp_soil)
temp_map_field.append(temp_field)
fields.append(temp_map_field)
@@ -22,64 +22,87 @@ def fill_map():
for j in range(10):
field = fields[i][j]
rect = field.get_rect()
- state = field.get_soil().get_state()
- water_level = field.get_soil().get_water_level()
- if state == False:
+ if field.get_plant().get_state() > 0 and field.get_plant().get_state() <= 1 * definitions.WHEAT_GROW_TIME + 1:
+ block = definitions.WHEATSTAGE1
+ elif field.get_plant().get_state() > 1 * definitions.WHEAT_GROW_TIME + 1 and field.get_plant().get_state() <= 2 * definitions.WHEAT_GROW_TIME + 1:
+ block = definitions.WHEATSTAGE2
+ elif field.get_plant().get_state() > 2 * definitions.WHEAT_GROW_TIME + 1 and field.get_plant().get_state() <= 3 * definitions.WHEAT_GROW_TIME + 1:
+ block = definitions.WHEATSTAGE3
+ elif field.get_plant().get_state() > 3 * definitions.WHEAT_GROW_TIME + 1 and field.get_plant().get_state() <= 4 * definitions.WHEAT_GROW_TIME + 1:
+ block = definitions.WHEATSTAGE4
+ elif field.get_plant().get_state() == 4 *definitions.WHEAT_GROW_TIME + 2:
+ block = definitions.WHEATSTAGE5
+ elif field.get_soil().get_state() is False:
block = definitions.DIRT
- elif water_level == False:
+ elif field.get_soil().get_state() is True and field.get_soil().get_water_level() is False:
block = definitions.FARMLAND
- else:
+ elif field.get_soil().get_state() is True and field.get_soil().get_water_level() is True:
block = definitions.FARMLANDMOIST
definitions.WIN.blit(block, (rect.x, rect.y))
-def do_work(tractor1_rectangle):
- x = int(tractor1_rectangle.x/100)
- y = int(tractor1_rectangle.y/100)
+def do_work(tractor1_rect):
+ x = int(tractor1_rect.x/100)
+ y = int(tractor1_rect.y/100)
field = fields[x][y]
- soil = field.get_soil()
- state = soil.get_state()
- water_level = soil.get_water_level()
- if state == False:
+ if field.get_soil().get_state() is False:
field.get_soil().set_state(True)
- elif water_level == False:
+ elif field.get_soil().get_state() is True and field.get_soil().get_water_level() is False:
field.get_soil().set_water_level(True)
-def draw_window(tractor1_rectangle):
+ elif field.get_plant().get_state() == 0:
+ field.get_plant().set_state(1)
+ elif 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)
+def draw_window(tractor1_rect):
fill_map()
- definitions.WIN.blit(definitions.TRACTOR, (tractor1_rectangle.x, tractor1_rectangle.y))
+ definitions.WIN.blit(definitions.TRACTOR, (tractor1_rect.x, tractor1_rect.y))
pygame.display.update()
-def is_move_allowed(move, tractor1_rectangle):
- if ((move == 1) and (tractor1_rectangle.y + definitions.VEL + definitions.BLOCK_SIZE <= definitions.HEIGHT)):
+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:
+ 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)):
return True
- elif ((move == 2) and (tractor1_rectangle.x - definitions.VEL >= 0)):
+ elif ((move == 2) and (tractor1_rect.x - definitions.BLOCK_SIZE >= 0)):
return True
- elif ((move == 3) and (tractor1_rectangle.x + definitions.VEL + definitions.BLOCK_SIZE <= definitions.WIDTH)):
+ elif ((move == 3) and (tractor1_rect.x + definitions.BLOCK_SIZE + definitions.BLOCK_SIZE <= definitions.WIDTH)):
return True
- elif ((move == 4) and (tractor1_rectangle.y - definitions.VEL >= 0)):
+ elif ((move == 4) and (tractor1_rect.y - definitions.BLOCK_SIZE >= 0)):
return True
else:
return False
-def tractor1_handle_movement(tractor1, tractor1_rectangle):
- random1 = random.randint(1, 4)
- do_work(tractor1_rectangle)
- if ((random1 == 1) and (is_move_allowed(1, tractor1_rectangle) == True)):
- tractor1.move_down()
- tractor1_rectangle.x = tractor1.get_x()
- tractor1_rectangle.y = tractor1.get_y()
- elif ((random1 == 2) and (is_move_allowed(2, tractor1_rectangle) == True)):
- tractor1.move_left()
- tractor1_rectangle.x = tractor1.get_x()
- tractor1_rectangle.y = tractor1.get_y()
- elif ((random1 == 3) and (is_move_allowed(3, tractor1_rectangle) == True)):
- tractor1.move_right()
- tractor1_rectangle.x = tractor1.get_x()
- tractor1_rectangle.y = tractor1.get_y()
- elif ((random1 == 4) and (is_move_allowed(4, tractor1_rectangle) == True)):
- tractor1.move_up()
- tractor1_rectangle.x = tractor1.get_x()
- tractor1_rectangle.y = tractor1.get_y()
+def tractor1_handle_movement(tractor1, tractor1_rect):
+ loop = True
+ while loop:
+ random1 = random.randint(1, 4)
+ if ((random1 == 1) and (is_move_allowed(1, tractor1_rect) is True)):
+ tractor1.move_down()
+ tractor1_rect.x = tractor1.get_x()
+ tractor1_rect.y = tractor1.get_y()
+ loop = False
+ elif ((random1 == 2) and (is_move_allowed(2, tractor1_rect) is True)):
+ tractor1.move_left()
+ tractor1_rect.x = tractor1.get_x()
+ tractor1_rect.y = tractor1.get_y()
+ loop = False
+ elif ((random1 == 3) and (is_move_allowed(3, tractor1_rect) is True)):
+ tractor1.move_right()
+ tractor1_rect.x = tractor1.get_x()
+ tractor1_rect.y = tractor1.get_y()
+ loop = False
+ elif ((random1 == 4) and (is_move_allowed(4, tractor1_rect) is True)):
+ tractor1.move_up()
+ tractor1_rect.x = tractor1.get_x()
+ tractor1_rect.y = tractor1.get_y()
+ loop = False
def main():
create_base_map()
- tractor1 = tractor.Tractor(400, 400)
- tractor1_rectangle = pygame.Rect(tractor1.get_x(), tractor1.get_y(), definitions.BLOCK_SIZE, definitions.BLOCK_SIZE)
+ tractor1 = tractor.Tractor(0, 0)
+ tractor1_rect = pygame.Rect(tractor1.get_x(), tractor1.get_y(), definitions.BLOCK_SIZE, definitions.BLOCK_SIZE)
+ draw_window(tractor1_rect)
clock = pygame.time.Clock()
run = True
while run:
@@ -87,8 +110,10 @@ def main():
for event in pygame.event.get():
if event.type == pygame.QUIT:
run = False
- tractor1_handle_movement(tractor1, tractor1_rectangle)
- draw_window(tractor1_rectangle)
+ tractor1_handle_movement(tractor1, tractor1_rect)
+ do_work(tractor1_rect)
+ grow_plants()
+ draw_window(tractor1_rect)
pygame.quit()
if __name__ == "__main__":
main()
\ No newline at end of file
diff --git a/resources/wheat_stage1.png b/resources/wheat_stage1.png
new file mode 100644
index 0000000..148f92e
Binary files /dev/null and b/resources/wheat_stage1.png differ
diff --git a/resources/wheat_stage2.png b/resources/wheat_stage2.png
new file mode 100644
index 0000000..80937d7
Binary files /dev/null and b/resources/wheat_stage2.png differ
diff --git a/resources/wheat_stage3.png b/resources/wheat_stage3.png
new file mode 100644
index 0000000..0706872
Binary files /dev/null and b/resources/wheat_stage3.png differ
diff --git a/resources/wheat_stage4.png b/resources/wheat_stage4.png
new file mode 100644
index 0000000..a61d1f2
Binary files /dev/null and b/resources/wheat_stage4.png differ
diff --git a/resources/wheat_stage5.png b/resources/wheat_stage5.png
new file mode 100644
index 0000000..159a850
Binary files /dev/null and b/resources/wheat_stage5.png differ
diff --git a/tractor.py b/tractor.py
index e798a12..a7df05f 100644
--- a/tractor.py
+++ b/tractor.py
@@ -12,10 +12,10 @@ class Tractor:
def set_y(self, y):
self.y = y
def move_down(self):
- self.y = self.y + definitions.VEL
+ self.y = self.y + definitions.BLOCK_SIZE
def move_left(self):
- self.x = self.x - definitions.VEL
+ self.x = self.x - definitions.BLOCK_SIZE
def move_right(self):
- self.x = self.x + definitions.VEL
+ self.x = self.x + definitions.BLOCK_SIZE
def move_up(self):
- self.y = self.y - definitions.VEL
\ No newline at end of file
+ self.y = self.y - definitions.BLOCK_SIZE
\ No newline at end of file