obracająca się grafika wózka

This commit is contained in:
Tomasz Adamczyk 2021-04-09 14:57:52 +02:00
parent f5eea95c5b
commit a357b56d58
11 changed files with 32 additions and 17 deletions

View File

@ -4,8 +4,9 @@
<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$/map.py" beforeDir="false" afterPath="$PROJECT_DIR$/map.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/py.py" beforeDir="false" afterPath="$PROJECT_DIR$/py.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/tractor.py" beforeDir="false" afterPath="$PROJECT_DIR$/tractor.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/resources/minecart_command_block.png" beforeDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -103,6 +104,7 @@
<workItem from="1617439271903" duration="2500000" />
<workItem from="1617794241086" duration="273000" />
<workItem from="1617966682687" duration="4169000" />
<workItem from="1617972419025" duration="598000" />
</task>
<servers />
</component>
@ -110,22 +112,22 @@
<option name="version" value="1" />
</component>
<component name="WindowStateProjectService">
<state width="1879" height="295" key="GridCell.Tab.0.bottom" timestamp="1617971848584">
<state width="1879" height="295" key="GridCell.Tab.0.bottom" timestamp="1617973021898">
<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="1617971848584" />
<state width="1879" height="295" key="GridCell.Tab.0.center" timestamp="1617971848584">
<state width="1879" height="295" key="GridCell.Tab.0.bottom/0.0.1920.1080@0.0.1920.1080" timestamp="1617973021898" />
<state width="1879" height="295" key="GridCell.Tab.0.center" timestamp="1617973021898">
<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="1617971848584" />
<state width="1879" height="295" key="GridCell.Tab.0.left" timestamp="1617971848584">
<state width="1879" height="295" key="GridCell.Tab.0.center/0.0.1920.1080@0.0.1920.1080" timestamp="1617973021898" />
<state width="1879" height="295" key="GridCell.Tab.0.left" timestamp="1617973021898">
<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="1617971848584" />
<state width="1879" height="295" key="GridCell.Tab.0.right" timestamp="1617971848584">
<state width="1879" height="295" key="GridCell.Tab.0.left/0.0.1920.1080@0.0.1920.1080" timestamp="1617973021898" />
<state width="1879" height="295" key="GridCell.Tab.0.right" timestamp="1617973021898">
<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="1617971848584" />
<state width="1879" height="295" key="GridCell.Tab.0.right/0.0.1920.1080@0.0.1920.1080" timestamp="1617973021898" />
<state width="1879" height="364" key="GridCell.Tab.1.bottom" timestamp="1617385468328">
<screen x="0" y="0" width="1920" height="1080" />
</state>
@ -142,12 +144,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="1617385468328" />
<state x="0" y="0" key="com.intellij.ide.util.TipDialog" timestamp="1617966682675">
<state x="0" y="0" key="com.intellij.ide.util.TipDialog" timestamp="1617972418605">
<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="1617966682675" />
<state x="0" y="0" key="com.intellij.ide.util.TipDialog/0.0.1920.1080@0.0.1920.1080" timestamp="1617972418605" />
</component>
<component name="com.intellij.coverage.CoverageDataManagerImpl">
<SUITE FILE_PATH="coverage/SmartTractor$py.coverage" NAME="py Coverage Results" MODIFIED="1617971807019" 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="1617972977225" 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.

View File

@ -45,8 +45,14 @@ SPONGE = pygame.image.load(os.path.join('resources', 'sponge.png'))
SPONGE = pygame.transform.scale(SPONGE, (BLOCK_SIZE, BLOCK_SIZE))
STATION = pygame.image.load(os.path.join('resources', 'rail_normal.png'))
STATION = pygame.transform.scale(STATION, (BLOCK_SIZE, BLOCK_SIZE))
TRACTOR = pygame.image.load(os.path.join('resources', 'minecart_command_block.png'))
TRACTOR = pygame.transform.scale(TRACTOR, (BLOCK_SIZE, BLOCK_SIZE))
TRACTOR_DIRECTION_EAST_TEXTURE = pygame.image.load(os.path.join('resources', 'minecart_command_block_east.png'))
TRACTOR_DIRECTION_EAST_TEXTURE = pygame.transform.scale(TRACTOR_DIRECTION_EAST_TEXTURE, (BLOCK_SIZE, BLOCK_SIZE))
TRACTOR_DIRECTION_NORTH_TEXTURE = pygame.image.load(os.path.join('resources', 'minecart_command_block_north.png'))
TRACTOR_DIRECTION_NORTH_TEXTURE = pygame.transform.scale(TRACTOR_DIRECTION_NORTH_TEXTURE, (BLOCK_SIZE, BLOCK_SIZE))
TRACTOR_DIRECTION_SOUTH_TEXTURE = pygame.image.load(os.path.join('resources', 'minecart_command_block_south.png'))
TRACTOR_DIRECTION_SOUTH_TEXTURE = pygame.transform.scale(TRACTOR_DIRECTION_SOUTH_TEXTURE, (BLOCK_SIZE, BLOCK_SIZE))
TRACTOR_DIRECTION_WEST_TEXTURE = pygame.image.load(os.path.join('resources', 'minecart_command_block_west.png'))
TRACTOR_DIRECTION_WEST_TEXTURE = pygame.transform.scale(TRACTOR_DIRECTION_WEST_TEXTURE, (BLOCK_SIZE, BLOCK_SIZE))
TRACTOR_DIRECTION_EAST = 2
TRACTOR_DIRECTION_NORTH = 1
TRACTOR_DIRECTION_SOUTH = 3

11
map.py
View File

@ -81,7 +81,14 @@ class Map:
elif block != definitions.DIRT or block != definitions.FARMLAND_DRY or block != definitions.FARMLAND_WET:
definitions.WINDOW.blit(definitions.FARMLAND_WET, (rect.x, rect.y))
definitions.WINDOW.blit(block, (rect.x, rect.y))
def draw_window(self, tractor1_rect): #rysuje mapę
def draw_window(self, tractor1, tractor1_rect): #rysuje mapę
self.fill_map()
definitions.WINDOW.blit(definitions.TRACTOR, (tractor1_rect.x, tractor1_rect.y))
if tractor1.get_direction() == definitions.TRACTOR_DIRECTION_EAST:
definitions.WINDOW.blit(definitions.TRACTOR_DIRECTION_EAST_TEXTURE, (tractor1_rect.x, tractor1_rect.y))
elif tractor1.get_direction() == definitions.TRACTOR_DIRECTION_NORTH:
definitions.WINDOW.blit(definitions.TRACTOR_DIRECTION_NORTH_TEXTURE, (tractor1_rect.x, tractor1_rect.y))
elif tractor1.get_direction() == definitions.TRACTOR_DIRECTION_SOUTH:
definitions.WINDOW.blit(definitions.TRACTOR_DIRECTION_SOUTH_TEXTURE, (tractor1_rect.x, tractor1_rect.y))
elif tractor1.get_direction() == definitions.TRACTOR_DIRECTION_WEST:
definitions.WINDOW.blit(definitions.TRACTOR_DIRECTION_WEST_TEXTURE, (tractor1_rect.x, tractor1_rect.y))
pygame.display.update()

2
py.py
View File

@ -22,7 +22,7 @@ def main():
for event in pygame.event.get():
if event.type == pygame.QUIT:
run = False
map1.draw_window(tractor1_rect)
map1.draw_window(tractor1, tractor1_rect)
tractor1.tractor1_handle_movement(tractor1_rect)
tractor1.do_work(map1, station1, tractor1_rect)
plant.Plant.grow_plants(map1)

Binary file not shown.

After

Width:  |  Height:  |  Size: 590 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 523 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 518 B

View File

Before

Width:  |  Height:  |  Size: 304 B

After

Width:  |  Height:  |  Size: 304 B