traktor losowo orający i podlewający pole
This commit is contained in:
parent
37cbaed6d3
commit
1f598d0896
@ -4,9 +4,8 @@
|
|||||||
<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$/definitions.py" beforeDir="false" afterPath="$PROJECT_DIR$/definitions.py" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/field.py" beforeDir="false" afterPath="$PROJECT_DIR$/field.py" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/plant.py" beforeDir="false" afterPath="$PROJECT_DIR$/plant.py" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/py.py" beforeDir="false" afterPath="$PROJECT_DIR$/py.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" />
|
||||||
</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" />
|
||||||
@ -83,6 +82,7 @@
|
|||||||
<workItem from="1616276134469" duration="1463000" />
|
<workItem from="1616276134469" duration="1463000" />
|
||||||
<workItem from="1616322081205" duration="4362000" />
|
<workItem from="1616322081205" duration="4362000" />
|
||||||
<workItem from="1616327331805" duration="7576000" />
|
<workItem from="1616327331805" duration="7576000" />
|
||||||
|
<workItem from="1616428378038" duration="453000" />
|
||||||
</task>
|
</task>
|
||||||
<servers />
|
<servers />
|
||||||
</component>
|
</component>
|
||||||
@ -90,22 +90,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="1616336008541">
|
<state width="1879" height="295" key="GridCell.Tab.0.bottom" timestamp="1616428834194">
|
||||||
<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="1616336008541" />
|
<state width="1879" height="295" key="GridCell.Tab.0.bottom/0.0.1920.1080@0.0.1920.1080" timestamp="1616428834194" />
|
||||||
<state width="1879" height="295" key="GridCell.Tab.0.center" timestamp="1616336008541">
|
<state width="1879" height="295" key="GridCell.Tab.0.center" timestamp="1616428834193">
|
||||||
<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="1616336008541" />
|
<state width="1879" height="295" key="GridCell.Tab.0.center/0.0.1920.1080@0.0.1920.1080" timestamp="1616428834193" />
|
||||||
<state width="1879" height="295" key="GridCell.Tab.0.left" timestamp="1616336008541">
|
<state width="1879" height="295" key="GridCell.Tab.0.left" timestamp="1616428834193">
|
||||||
<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="1616336008541" />
|
<state width="1879" height="295" key="GridCell.Tab.0.left/0.0.1920.1080@0.0.1920.1080" timestamp="1616428834193" />
|
||||||
<state width="1879" height="295" key="GridCell.Tab.0.right" timestamp="1616336008541">
|
<state width="1879" height="295" key="GridCell.Tab.0.right" timestamp="1616428834194">
|
||||||
<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="1616336008541" />
|
<state width="1879" height="295" key="GridCell.Tab.0.right/0.0.1920.1080@0.0.1920.1080" timestamp="1616428834194" />
|
||||||
<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>
|
||||||
@ -122,12 +122,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="1616327335999">
|
<state x="0" y="0" key="com.intellij.ide.util.TipDialog" timestamp="1616428379187">
|
||||||
<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="1616327335999" />
|
<state x="0" y="0" key="com.intellij.ide.util.TipDialog/0.0.1920.1080@0.0.1920.1080" timestamp="1616428379187" />
|
||||||
</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="1616335958059" 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="1616428775958" 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.
@ -5,6 +5,8 @@ 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'))
|
||||||
FARMLAND = pygame.transform.scale(FARMLAND, (BLOCK_SIZE, BLOCK_SIZE))
|
FARMLAND = pygame.transform.scale(FARMLAND, (BLOCK_SIZE, BLOCK_SIZE))
|
||||||
|
FARMLANDMOIST = pygame.image.load(os.path.join('resources', 'farmland_moist.png'))
|
||||||
|
FARMLANDMOIST = pygame.transform.scale(FARMLANDMOIST, (BLOCK_SIZE, BLOCK_SIZE))
|
||||||
FPS = 1
|
FPS = 1
|
||||||
WIDTH, HEIGHT = 1000, 1000
|
WIDTH, HEIGHT = 1000, 1000
|
||||||
WIN = pygame.display.set_mode((WIDTH, HEIGHT))
|
WIN = pygame.display.set_mode((WIDTH, HEIGHT))
|
||||||
|
20
py.py
20
py.py
@ -22,9 +22,26 @@ def fill_map():
|
|||||||
for j in range(10):
|
for j in range(10):
|
||||||
field = fields[i][j]
|
field = fields[i][j]
|
||||||
rect = field.get_rect()
|
rect = field.get_rect()
|
||||||
if field.get_soil().get_state() == False:
|
state = field.get_soil().get_state()
|
||||||
|
water_level = field.get_soil().get_water_level()
|
||||||
|
if state == False:
|
||||||
block = definitions.DIRT
|
block = definitions.DIRT
|
||||||
|
elif water_level == False:
|
||||||
|
block = definitions.FARMLAND
|
||||||
|
else:
|
||||||
|
block = definitions.FARMLANDMOIST
|
||||||
definitions.WIN.blit(block, (rect.x, rect.y))
|
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)
|
||||||
|
field = fields[x][y]
|
||||||
|
soil = field.get_soil()
|
||||||
|
state = soil.get_state()
|
||||||
|
water_level = soil.get_water_level()
|
||||||
|
if state == False:
|
||||||
|
field.get_soil().set_state(True)
|
||||||
|
elif water_level == False:
|
||||||
|
field.get_soil().set_water_level(True)
|
||||||
def draw_window(tractor1_rectangle):
|
def draw_window(tractor1_rectangle):
|
||||||
fill_map()
|
fill_map()
|
||||||
definitions.WIN.blit(definitions.TRACTOR, (tractor1_rectangle.x, tractor1_rectangle.y))
|
definitions.WIN.blit(definitions.TRACTOR, (tractor1_rectangle.x, tractor1_rectangle.y))
|
||||||
@ -42,6 +59,7 @@ def is_move_allowed(move, tractor1_rectangle):
|
|||||||
return False
|
return False
|
||||||
def tractor1_handle_movement(tractor1, tractor1_rectangle):
|
def tractor1_handle_movement(tractor1, tractor1_rectangle):
|
||||||
random1 = random.randint(1, 4)
|
random1 = random.randint(1, 4)
|
||||||
|
do_work(tractor1_rectangle)
|
||||||
if ((random1 == 1) and (is_move_allowed(1, tractor1_rectangle) == True)):
|
if ((random1 == 1) and (is_move_allowed(1, tractor1_rectangle) == True)):
|
||||||
tractor1.move_down()
|
tractor1.move_down()
|
||||||
tractor1_rectangle.x = tractor1.get_x()
|
tractor1_rectangle.x = tractor1.get_x()
|
||||||
|
2
soil.py
2
soil.py
@ -8,5 +8,5 @@ class Soil:
|
|||||||
self.state = state
|
self.state = state
|
||||||
def get_water_level(self):
|
def get_water_level(self):
|
||||||
return self.water_level
|
return self.water_level
|
||||||
def set_required_water_level(self, water_level):
|
def set_water_level(self, water_level):
|
||||||
self.water_level = water_level
|
self.water_level = water_level
|
Loading…
Reference in New Issue
Block a user