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="">
|
||||
<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$/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$/soil.py" beforeDir="false" afterPath="$PROJECT_DIR$/soil.py" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
@ -83,6 +82,7 @@
|
||||
<workItem from="1616276134469" duration="1463000" />
|
||||
<workItem from="1616322081205" duration="4362000" />
|
||||
<workItem from="1616327331805" duration="7576000" />
|
||||
<workItem from="1616428378038" duration="453000" />
|
||||
</task>
|
||||
<servers />
|
||||
</component>
|
||||
@ -90,22 +90,22 @@
|
||||
<option name="version" value="1" />
|
||||
</component>
|
||||
<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" />
|
||||
</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.center" 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="1616428834193">
|
||||
<screen x="0" y="0" width="1920" height="1080" />
|
||||
</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.left" 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="1616428834193">
|
||||
<screen x="0" y="0" width="1920" height="1080" />
|
||||
</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.right" 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="1616428834194">
|
||||
<screen x="0" y="0" width="1920" height="1080" />
|
||||
</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">
|
||||
<screen x="0" y="0" width="1920" height="1080" />
|
||||
</state>
|
||||
@ -122,12 +122,12 @@
|
||||
<screen x="0" y="0" width="1920" height="1080" />
|
||||
</state>
|
||||
<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" />
|
||||
</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 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>
|
||||
</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))
|
||||
FARMLAND = pygame.image.load(os.path.join('resources', 'farmland.png'))
|
||||
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
|
||||
WIDTH, HEIGHT = 1000, 1000
|
||||
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):
|
||||
field = fields[i][j]
|
||||
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
|
||||
elif water_level == False:
|
||||
block = definitions.FARMLAND
|
||||
else:
|
||||
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)
|
||||
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):
|
||||
fill_map()
|
||||
definitions.WIN.blit(definitions.TRACTOR, (tractor1_rectangle.x, tractor1_rectangle.y))
|
||||
@ -42,6 +59,7 @@ def is_move_allowed(move, tractor1_rectangle):
|
||||
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()
|
||||
|
Loading…
Reference in New Issue
Block a user