działający losowy ruch
This commit is contained in:
parent
5100e3e060
commit
d8cf576ddf
@ -79,6 +79,7 @@
|
|||||||
<workItem from="1615670854240" duration="68000" />
|
<workItem from="1615670854240" duration="68000" />
|
||||||
<workItem from="1616276134469" duration="1463000" />
|
<workItem from="1616276134469" duration="1463000" />
|
||||||
<workItem from="1616322081205" duration="4362000" />
|
<workItem from="1616322081205" duration="4362000" />
|
||||||
|
<workItem from="1616327331805" duration="551000" />
|
||||||
</task>
|
</task>
|
||||||
<servers />
|
<servers />
|
||||||
</component>
|
</component>
|
||||||
@ -86,22 +87,22 @@
|
|||||||
<option name="version" value="1" />
|
<option name="version" value="1" />
|
||||||
</component>
|
</component>
|
||||||
<component name="WindowStateProjectService">
|
<component name="WindowStateProjectService">
|
||||||
<state width="1879" height="364" key="GridCell.Tab.0.bottom" timestamp="1616326478875">
|
<state width="1879" height="295" key="GridCell.Tab.0.bottom" timestamp="1616327942000">
|
||||||
<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.0.bottom/0.0.1920.1080@0.0.1920.1080" timestamp="1616326478875" />
|
<state width="1879" height="295" key="GridCell.Tab.0.bottom/0.0.1920.1080@0.0.1920.1080" timestamp="1616327942000" />
|
||||||
<state width="1879" height="364" key="GridCell.Tab.0.center" timestamp="1616326478875">
|
<state width="1879" height="295" key="GridCell.Tab.0.center" timestamp="1616327942000">
|
||||||
<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.0.center/0.0.1920.1080@0.0.1920.1080" timestamp="1616326478875" />
|
<state width="1879" height="295" key="GridCell.Tab.0.center/0.0.1920.1080@0.0.1920.1080" timestamp="1616327942000" />
|
||||||
<state width="1879" height="364" key="GridCell.Tab.0.left" timestamp="1616326478875">
|
<state width="1879" height="295" key="GridCell.Tab.0.left" timestamp="1616327942000">
|
||||||
<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.0.left/0.0.1920.1080@0.0.1920.1080" timestamp="1616326478875" />
|
<state width="1879" height="295" key="GridCell.Tab.0.left/0.0.1920.1080@0.0.1920.1080" timestamp="1616327942000" />
|
||||||
<state width="1879" height="364" key="GridCell.Tab.0.right" timestamp="1616326478875">
|
<state width="1879" height="295" key="GridCell.Tab.0.right" timestamp="1616327942000">
|
||||||
<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.0.right/0.0.1920.1080@0.0.1920.1080" timestamp="1616326478875" />
|
<state width="1879" height="295" key="GridCell.Tab.0.right/0.0.1920.1080@0.0.1920.1080" timestamp="1616327942000" />
|
||||||
<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>
|
||||||
@ -118,12 +119,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="1616322080552">
|
<state x="0" y="0" key="com.intellij.ide.util.TipDialog" timestamp="1616327335999">
|
||||||
<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="1616322080552" />
|
<state x="0" y="0" key="com.intellij.ide.util.TipDialog/0.0.1920.1080@0.0.1920.1080" timestamp="1616327335999" />
|
||||||
</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="1616326392782" 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="1616327941991" 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.
19
py.py
19
py.py
@ -11,22 +11,31 @@ def draw_window(tractor1_rectangle):
|
|||||||
definitions.WIN.blit(definitions.TRACTOR, (tractor1_rectangle.x, tractor1_rectangle.y))
|
definitions.WIN.blit(definitions.TRACTOR, (tractor1_rectangle.x, tractor1_rectangle.y))
|
||||||
pygame.display.update()
|
pygame.display.update()
|
||||||
def is_move_allowed(move, tractor1_rectangle):
|
def is_move_allowed(move, tractor1_rectangle):
|
||||||
return True
|
if ((move == 1) and (tractor1_rectangle.y + definitions.VEL + definitions.TRACTOR_HEIGHT <= definitions.HEIGHT)):
|
||||||
|
return True
|
||||||
|
elif ((move == 2) and (tractor1_rectangle.x - definitions.VEL >= 0)):
|
||||||
|
return True
|
||||||
|
elif ((move == 3) and (tractor1_rectangle.x + definitions.VEL + definitions.TRACTOR_WIDTH <= definitions.WIDTH)):
|
||||||
|
return True
|
||||||
|
elif ((move == 4) and (tractor1_rectangle.y - definitions.VEL >= 0)):
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
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)
|
||||||
if (random == 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()
|
||||||
tractor1_rectangle.y = tractor1.get_y()
|
tractor1_rectangle.y = tractor1.get_y()
|
||||||
elif (random == 2 and is_move_allowed(2, tractor1_rectangle) == True):
|
elif ((random1 == 2) and (is_move_allowed(2, tractor1_rectangle) == True)):
|
||||||
tractor1.move_left()
|
tractor1.move_left()
|
||||||
tractor1_rectangle.x = tractor1.get_x()
|
tractor1_rectangle.x = tractor1.get_x()
|
||||||
tractor1_rectangle.y = tractor1.get_y()
|
tractor1_rectangle.y = tractor1.get_y()
|
||||||
elif (random == 3 and is_move_allowed(3, tractor1_rectangle) == True):
|
elif ((random1 == 3) and (is_move_allowed(3, tractor1_rectangle) == True)):
|
||||||
tractor1.move_right()
|
tractor1.move_right()
|
||||||
tractor1_rectangle.x = tractor1.get_x()
|
tractor1_rectangle.x = tractor1.get_x()
|
||||||
tractor1_rectangle.y = tractor1.get_y()
|
tractor1_rectangle.y = tractor1.get_y()
|
||||||
elif (random == 4 and is_move_allowed(4, tractor1_rectangle) == True):
|
elif ((random1 == 4) and (is_move_allowed(4, tractor1_rectangle) == True)):
|
||||||
tractor1.move_up()
|
tractor1.move_up()
|
||||||
tractor1_rectangle.x = tractor1.get_x()
|
tractor1_rectangle.x = tractor1.get_x()
|
||||||
tractor1_rectangle.y = tractor1.get_y()
|
tractor1_rectangle.y = tractor1.get_y()
|
||||||
|
Loading…
Reference in New Issue
Block a user