dodane grafiki, ilość seedsów, liczność zbiorów

This commit is contained in:
Tomasz Adamczyk 2021-03-31 12:56:29 +02:00
parent 779d616ec6
commit ca9a8506f6
21 changed files with 74 additions and 26 deletions

View File

@ -3,6 +3,10 @@
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="56453584-72bd-49f4-a39c-fccf91ab20c6" name="Default Changelist" comment=""> <list default="true" id="56453584-72bd-49f4-a39c-fccf91ab20c6" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/definitions.py" beforeDir="false" afterPath="$PROJECT_DIR$/definitions.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/py.py" beforeDir="false" afterPath="$PROJECT_DIR$/py.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/soil.py" beforeDir="false" afterPath="$PROJECT_DIR$/soil.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/tractor.py" beforeDir="false" afterPath="$PROJECT_DIR$/tractor.py" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -87,6 +91,8 @@
<workItem from="1616874983490" duration="2052000" /> <workItem from="1616874983490" duration="2052000" />
<workItem from="1617029025208" duration="4359000" /> <workItem from="1617029025208" duration="4359000" />
<workItem from="1617101776539" duration="127000" /> <workItem from="1617101776539" duration="127000" />
<workItem from="1617179845457" duration="82000" />
<workItem from="1617183365349" duration="4399000" />
</task> </task>
<servers /> <servers />
</component> </component>
@ -94,22 +100,22 @@
<option name="version" value="1" /> <option name="version" value="1" />
</component> </component>
<component name="WindowStateProjectService"> <component name="WindowStateProjectService">
<state width="1879" height="295" key="GridCell.Tab.0.bottom" timestamp="1617033424354"> <state width="1879" height="295" key="GridCell.Tab.0.bottom" timestamp="1617188117951">
<screen x="0" y="0" width="1920" height="1080" /> <screen x="0" y="0" width="1920" height="1080" />
</state> </state>
<state width="1879" height="295" key="GridCell.Tab.0.bottom/0.0.1920.1080@0.0.1920.1080" timestamp="1617033424354" /> <state width="1879" height="295" key="GridCell.Tab.0.bottom/0.0.1920.1080@0.0.1920.1080" timestamp="1617188117951" />
<state width="1879" height="295" key="GridCell.Tab.0.center" timestamp="1617033424354"> <state width="1879" height="295" key="GridCell.Tab.0.center" timestamp="1617188117951">
<screen x="0" y="0" width="1920" height="1080" /> <screen x="0" y="0" width="1920" height="1080" />
</state> </state>
<state width="1879" height="295" key="GridCell.Tab.0.center/0.0.1920.1080@0.0.1920.1080" timestamp="1617033424354" /> <state width="1879" height="295" key="GridCell.Tab.0.center/0.0.1920.1080@0.0.1920.1080" timestamp="1617188117951" />
<state width="1879" height="295" key="GridCell.Tab.0.left" timestamp="1617033424354"> <state width="1879" height="295" key="GridCell.Tab.0.left" timestamp="1617188117951">
<screen x="0" y="0" width="1920" height="1080" /> <screen x="0" y="0" width="1920" height="1080" />
</state> </state>
<state width="1879" height="295" key="GridCell.Tab.0.left/0.0.1920.1080@0.0.1920.1080" timestamp="1617033424354" /> <state width="1879" height="295" key="GridCell.Tab.0.left/0.0.1920.1080@0.0.1920.1080" timestamp="1617188117951" />
<state width="1879" height="295" key="GridCell.Tab.0.right" timestamp="1617033424354"> <state width="1879" height="295" key="GridCell.Tab.0.right" timestamp="1617188117951">
<screen x="0" y="0" width="1920" height="1080" /> <screen x="0" y="0" width="1920" height="1080" />
</state> </state>
<state width="1879" height="295" key="GridCell.Tab.0.right/0.0.1920.1080@0.0.1920.1080" timestamp="1617033424354" /> <state width="1879" height="295" key="GridCell.Tab.0.right/0.0.1920.1080@0.0.1920.1080" timestamp="1617188117951" />
<state width="1879" height="364" key="GridCell.Tab.1.bottom" timestamp="1616326478876"> <state width="1879" height="364" key="GridCell.Tab.1.bottom" timestamp="1616326478876">
<screen x="0" y="0" width="1920" height="1080" /> <screen x="0" y="0" width="1920" height="1080" />
</state> </state>
@ -126,12 +132,12 @@
<screen x="0" y="0" width="1920" height="1080" /> <screen x="0" y="0" width="1920" height="1080" />
</state> </state>
<state width="1879" height="364" key="GridCell.Tab.1.right/0.0.1920.1080@0.0.1920.1080" timestamp="1616326478875" /> <state width="1879" height="364" key="GridCell.Tab.1.right/0.0.1920.1080@0.0.1920.1080" timestamp="1616326478875" />
<state x="0" y="0" key="com.intellij.ide.util.TipDialog" timestamp="1617101776536"> <state x="0" y="0" key="com.intellij.ide.util.TipDialog" timestamp="1617183372447">
<screen x="0" y="0" width="1920" height="1080" /> <screen x="0" y="0" width="1920" height="1080" />
</state> </state>
<state x="0" y="0" key="com.intellij.ide.util.TipDialog/0.0.1920.1080@0.0.1920.1080" timestamp="1617101776536" /> <state x="0" y="0" key="com.intellij.ide.util.TipDialog/0.0.1920.1080@0.0.1920.1080" timestamp="1617183372447" />
</component> </component>
<component name="com.intellij.coverage.CoverageDataManagerImpl"> <component name="com.intellij.coverage.CoverageDataManagerImpl">
<SUITE FILE_PATH="coverage/SmartTractor$py.coverage" NAME="py Coverage Results" MODIFIED="1617033003775" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" /> <SUITE FILE_PATH="coverage/SmartTractor$py.coverage" NAME="py Coverage Results" MODIFIED="1617188104059" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
</component> </component>
</project> </project>

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,6 +1,22 @@
import os import os
import pygame import pygame
BLOCK_SIZE = 100 BLOCK_SIZE = 100
BEETROOTSTAGE1 = pygame.image.load(os.path.join('resources', 'beetroots_stage1.png'))
BEETROOTSTAGE1 = pygame.transform.scale(BEETROOTSTAGE1, (BLOCK_SIZE, BLOCK_SIZE))
BEETROOTSTAGE2 = pygame.image.load(os.path.join('resources', 'beetroots_stage2.png'))
BEETROOTSTAGE2 = pygame.transform.scale(BEETROOTSTAGE2, (BLOCK_SIZE, BLOCK_SIZE))
BEETROOTSTAGE3 = pygame.image.load(os.path.join('resources', 'beetroots_stage3.png'))
BEETROOTSTAGE3 = pygame.transform.scale(BEETROOTSTAGE3, (BLOCK_SIZE, BLOCK_SIZE))
BEETROOTSTAGE4 = pygame.image.load(os.path.join('resources', 'beetroots_stage4.png'))
BEETROOTSTAGE4 = pygame.transform.scale(BEETROOTSTAGE4, (BLOCK_SIZE, BLOCK_SIZE))
CARROTSTAGE1 = pygame.image.load(os.path.join('resources', 'carrots_stage1.png'))
CARROTSTAGE1 = pygame.transform.scale(CARROTSTAGE1, (BLOCK_SIZE, BLOCK_SIZE))
CARROTSTAGE2 = pygame.image.load(os.path.join('resources', 'carrots_stage2.png'))
CARROTSTAGE2 = pygame.transform.scale(CARROTSTAGE2, (BLOCK_SIZE, BLOCK_SIZE))
CARROTSTAGE3 = pygame.image.load(os.path.join('resources', 'carrots_stage3.png'))
CARROTSTAGE3 = pygame.transform.scale(CARROTSTAGE3, (BLOCK_SIZE, BLOCK_SIZE))
CARROTSTAGE4 = pygame.image.load(os.path.join('resources', 'carrots_stage4.png'))
CARROTSTAGE4 = pygame.transform.scale(CARROTSTAGE4, (BLOCK_SIZE, BLOCK_SIZE))
DIRT = pygame.image.load(os.path.join('resources', 'dirt.png')) DIRT = pygame.image.load(os.path.join('resources', 'dirt.png'))
DIRT = pygame.transform.scale(DIRT, (BLOCK_SIZE, BLOCK_SIZE)) DIRT = pygame.transform.scale(DIRT, (BLOCK_SIZE, BLOCK_SIZE))
FARMLAND = pygame.image.load(os.path.join('resources', 'farmland.png')) FARMLAND = pygame.image.load(os.path.join('resources', 'farmland.png'))
@ -8,14 +24,22 @@ FARMLAND = pygame.transform.scale(FARMLAND, (BLOCK_SIZE, BLOCK_SIZE))
FARMLANDMOIST = pygame.image.load(os.path.join('resources', 'farmland_moist.png')) FARMLANDMOIST = pygame.image.load(os.path.join('resources', 'farmland_moist.png'))
FARMLANDMOIST = pygame.transform.scale(FARMLANDMOIST, (BLOCK_SIZE, BLOCK_SIZE)) FARMLANDMOIST = pygame.transform.scale(FARMLANDMOIST, (BLOCK_SIZE, BLOCK_SIZE))
FPS = 1 FPS = 1
POTATOSTAGE1 = pygame.image.load(os.path.join('resources', 'potatoes_stage1.png'))
POTATOSTAGE1 = pygame.transform.scale(POTATOSTAGE1, (BLOCK_SIZE, BLOCK_SIZE))
POTATOSTAGE2 = pygame.image.load(os.path.join('resources', 'potatoes_stage2.png'))
POTATOSTAGE2 = pygame.transform.scale(POTATOSTAGE2, (BLOCK_SIZE, BLOCK_SIZE))
POTATOSTAGE3 = pygame.image.load(os.path.join('resources', 'potatoes_stage3.png'))
POTATOSTAGE3 = pygame.transform.scale(POTATOSTAGE3, (BLOCK_SIZE, BLOCK_SIZE))
WIDTH, HEIGHT = 1000, 1000 WIDTH, HEIGHT = 1000, 1000
WIN = pygame.display.set_mode((WIDTH, HEIGHT)) WIN = pygame.display.set_mode((WIDTH, HEIGHT))
TRACTOR = pygame.image.load(os.path.join('resources', 'tractor.png')) TRACTOR = pygame.image.load(os.path.join('resources', 'tractor.png'))
TRACTOR = pygame.transform.scale(TRACTOR, (BLOCK_SIZE, BLOCK_SIZE)) TRACTOR = pygame.transform.scale(TRACTOR, (BLOCK_SIZE, BLOCK_SIZE))
TRACTOR_FERTILIZER = 2 TRACTOR_FERTILIZER = 2
TRACTOR_FUEL = 5 TRACTOR_FUEL = 200
TRACTOR_WATER_LEVEL = 3 TRACTOR_AMOUNT_OF_SEEDS_EACH_TYPE = 20
WHEAT_GROW_TIME = 50 TRACTOR_MAXIMUM_COLLECTED_PLANTS = 80
TRACTOR_WATER_LEVEL = 40
WHEAT_GROW_TIME = 5
WHEAT_MAXIMUM_STATE = 21 WHEAT_MAXIMUM_STATE = 21
WHEATSTAGE1 = pygame.image.load(os.path.join('resources', 'wheat_stage1.png')) WHEATSTAGE1 = pygame.image.load(os.path.join('resources', 'wheat_stage1.png'))
WHEATSTAGE1 = pygame.transform.scale(WHEATSTAGE1, (BLOCK_SIZE, BLOCK_SIZE)) WHEATSTAGE1 = pygame.transform.scale(WHEATSTAGE1, (BLOCK_SIZE, BLOCK_SIZE))

16
py.py
View File

@ -12,7 +12,7 @@ def create_base_map():
temp_map_field = [] temp_map_field = []
for j in range(10): for j in range(10):
temp_rect = pygame.Rect(i * definitions.BLOCK_SIZE, j * definitions.BLOCK_SIZE, definitions.BLOCK_SIZE, definitions.BLOCK_SIZE) temp_rect = pygame.Rect(i * definitions.BLOCK_SIZE, j * definitions.BLOCK_SIZE, definitions.BLOCK_SIZE, definitions.BLOCK_SIZE)
temp_soil = soil.Soil(None, False, False) temp_soil = soil.Soil(False, False, False)
temp_plant = plant.Plant("wheat", 0) temp_plant = plant.Plant("wheat", 0)
temp_field = field.Field(temp_plant, temp_rect, temp_soil) temp_field = field.Field(temp_plant, temp_rect, temp_soil)
temp_map_field.append(temp_field) temp_map_field.append(temp_field)
@ -48,16 +48,20 @@ def do_work(tractor1, tractor1_rect):
elif field.get_soil().get_state() is True and field.get_soil().get_water_level() is False and tractor1.get_water_level() > 0: elif field.get_soil().get_state() is True and field.get_soil().get_water_level() is False and tractor1.get_water_level() > 0:
tractor1.set_water_level(tractor1.get_water_level() - 1) tractor1.set_water_level(tractor1.get_water_level() - 1)
field.get_soil().set_water_level(True) field.get_soil().set_water_level(True)
elif field.get_soil().get_state() is True and field.get_soil().get_water_level() is True and field.get_plant().get_state() == 0: elif field.get_soil().get_state() is True and field.get_soil().get_water_level() is True and field.get_plant().get_state() == 0 and tractor1.get_amount_of_seeds("wheat") > 0:
tractor1.set_amount_of_seeds("wheat", tractor1.get_amount_of_seeds("wheat") - 1)
field.get_plant().set_name("wheat") field.get_plant().set_name("wheat")
field.get_plant().set_state(1) field.get_plant().set_state(1)
elif field.get_plant().get_name() == "wheat" and field.get_plant().get_state() > 0 and field.get_plant().get_state() < definitions.WHEAT_MAXIMUM_STATE - definitions.WHEAT_GROW_TIME and tractor1.get_fertilizer("wheat") > 0: elif field.get_plant().get_name() == "wheat" and field.get_plant().get_state() > 0 and field.get_plant().get_state() < definitions.WHEAT_MAXIMUM_STATE - definitions.WHEAT_GROW_TIME and tractor1.get_fertilizer("wheat") > 0 and field.get_soil().get_is_fertilized() is False:
tractor1.set_fertilizer("wheat", (tractor1.get_fertilizer("wheat") - 1)) tractor1.set_fertilizer("wheat", (tractor1.get_fertilizer("wheat") - 1))
field.get_soil().set_is_fertilized(True)
field.get_plant().set_state(field.get_plant().get_state() + definitions.WHEAT_GROW_TIME) field.get_plant().set_state(field.get_plant().get_state() + definitions.WHEAT_GROW_TIME)
elif field.get_plant().get_name() == "wheat" and 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 and tractor1.get_all_collected_plants() < definitions.TRACTOR_MAXIMUM_COLLECTED_PLANTS:
field.get_plant().set_state(0) field.get_plant().set_state(0)
field.get_soil().set_is_fertilized(False)
field.get_soil().set_water_level(False) field.get_soil().set_water_level(False)
field.get_soil().set_state(False) field.get_soil().set_state(False)
tractor1.set_collected_plants("wheat", tractor1.get_collected_plants("wheat") + 1)
def draw_window(tractor1_rect): def draw_window(tractor1_rect):
fill_map() fill_map()
definitions.WIN.blit(definitions.TRACTOR, (tractor1_rect.x, tractor1_rect.y)) definitions.WIN.blit(definitions.TRACTOR, (tractor1_rect.x, tractor1_rect.y))
@ -109,8 +113,10 @@ def tractor1_handle_movement(tractor1, tractor1_rect):
tractor1.set_water_level(definitions.TRACTOR_WATER_LEVEL) tractor1.set_water_level(definitions.TRACTOR_WATER_LEVEL)
def main(): def main():
create_base_map() create_base_map()
amount_of_seeds_dict = {"beetroot": definitions.TRACTOR_AMOUNT_OF_SEEDS_EACH_TYPE, "carrot": definitions.TRACTOR_AMOUNT_OF_SEEDS_EACH_TYPE, "potato": definitions.TRACTOR_AMOUNT_OF_SEEDS_EACH_TYPE, "wheat": definitions.TRACTOR_AMOUNT_OF_SEEDS_EACH_TYPE}
collected_plants_dict = {"beetroot": 0, "carrot": 0, "potato": 0, "wheat": 0}
fertilizer_dict = {"beetroot": definitions.TRACTOR_FERTILIZER, "carrot": definitions.TRACTOR_FERTILIZER, "potato": definitions.TRACTOR_FERTILIZER, "wheat": definitions.TRACTOR_FERTILIZER} fertilizer_dict = {"beetroot": definitions.TRACTOR_FERTILIZER, "carrot": definitions.TRACTOR_FERTILIZER, "potato": definitions.TRACTOR_FERTILIZER, "wheat": definitions.TRACTOR_FERTILIZER}
tractor1 = tractor.Tractor(fertilizer_dict, definitions.TRACTOR_FUEL, definitions.TRACTOR_WATER_LEVEL ,0, 0) tractor1 = tractor.Tractor(amount_of_seeds_dict, collected_plants_dict, fertilizer_dict, definitions.TRACTOR_FUEL, definitions.TRACTOR_WATER_LEVEL ,0, 0)
tractor1_rect = pygame.Rect(tractor1.get_x(), tractor1.get_y(), definitions.BLOCK_SIZE, definitions.BLOCK_SIZE) tractor1_rect = pygame.Rect(tractor1.get_x(), tractor1.get_y(), definitions.BLOCK_SIZE, definitions.BLOCK_SIZE)
clock = pygame.time.Clock() clock = pygame.time.Clock()
run = True run = True

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

12
soil.py
View File

@ -1,12 +1,12 @@
class Soil: class Soil:
def __init__(self, fertilizer, state, water_level): def __init__(self, is_fertilized, state, water_level):
self.fertilizer = fertilizer self.is_fertilized = is_fertilized
self.state = state self.state = state
self.water_level = water_level self.water_level = water_level
def get_fertilizer(self): def get_is_fertilized(self):
return self.fertilizer return self.is_fertilized
def set_fertilizer(self, fertilizer): def set_is_fertilized(self, is_fertilized):
self.fertilizer = fertilizer self.is_fertilized = is_fertilized
def get_state(self): def get_state(self):
return self.state return self.state
def set_state(self, state): def set_state(self, state):

View File

@ -1,11 +1,23 @@
import definitions import definitions
class Tractor: class Tractor:
def __init__(self, fertilizer, fuel, water_level, x, y): def __init__(self, amount_of_seeds, collected_plants, fertilizer, fuel, water_level, x, y):
self.amount_of_seeds = amount_of_seeds
self.collected_plants = collected_plants
self.fertilizer = fertilizer self.fertilizer = fertilizer
self.fuel = fuel self.fuel = fuel
self.water_level = water_level self.water_level = water_level
self.x = x self.x = x
self.y = y self.y = y
def get_amount_of_seeds(self, name):
return self.amount_of_seeds[name]
def set_amount_of_seeds(self, name, value):
self.amount_of_seeds[name] = value
def get_all_collected_plants(self):
return self.collected_plants["beetroot"] + self.collected_plants["carrot"] + self.collected_plants["potato"] + self.collected_plants["wheat"]
def get_collected_plants(self, name):
return self.collected_plants[name]
def set_collected_plants(self, name, value):
self.collected_plants[name] = value
def get_fertilizer(self, name): def get_fertilizer(self, name):
return self.fertilizer[name] return self.fertilizer[name]
def set_fertilizer(self, name, value): def set_fertilizer(self, name, value):