zmiany w definitions

This commit is contained in:
Tomasz Adamczyk 2021-04-02 19:46:23 +02:00
parent dc5a04a069
commit 9355d382e5
4 changed files with 31 additions and 49 deletions

View File

@ -5,26 +5,6 @@
<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$/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$/resources/beetroots_stage1.png" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/resources/beetroots_stage2.png" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/resources/beetroots_stage3.png" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/resources/beetroots_stage4.png" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/resources/carrots_stage1.png" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/resources/carrots_stage2.png" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/resources/carrots_stage3.png" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/resources/carrots_stage4.png" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/resources/farmland.png" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/resources/farmland_moist.png" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/resources/potatoes_stage1.png" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/resources/potatoes_stage2.png" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/resources/potatoes_stage3.png" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/resources/potatoes_stage4.png" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/resources/tractor.png" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/resources/wheat_stage1.png" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/resources/wheat_stage2.png" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/resources/wheat_stage3.png" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/resources/wheat_stage4.png" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/resources/wheat_stage5.png" beforeDir="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" />
@ -115,6 +95,7 @@
<workItem from="1617367883128" duration="2815000" /> <workItem from="1617367883128" duration="2815000" />
<workItem from="1617370723478" duration="1838000" /> <workItem from="1617370723478" duration="1838000" />
<workItem from="1617372800679" duration="949000" /> <workItem from="1617372800679" duration="949000" />
<workItem from="1617383739568" duration="1714000" />
</task> </task>
<servers /> <servers />
</component> </component>
@ -122,44 +103,44 @@
<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="1617373756802"> <state width="1879" height="364" key="GridCell.Tab.0.bottom" timestamp="1617385468328">
<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="1617373756802" /> <state width="1879" height="364" key="GridCell.Tab.0.bottom/0.0.1920.1080@0.0.1920.1080" timestamp="1617385468328" />
<state width="1879" height="364" key="GridCell.Tab.0.center" timestamp="1617373756802"> <state width="1879" height="364" key="GridCell.Tab.0.center" timestamp="1617385468327">
<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="1617373756802" /> <state width="1879" height="364" key="GridCell.Tab.0.center/0.0.1920.1080@0.0.1920.1080" timestamp="1617385468327" />
<state width="1879" height="364" key="GridCell.Tab.0.left" timestamp="1617373756802"> <state width="1879" height="364" key="GridCell.Tab.0.left" timestamp="1617385468327">
<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="1617373756802" /> <state width="1879" height="364" key="GridCell.Tab.0.left/0.0.1920.1080@0.0.1920.1080" timestamp="1617385468327" />
<state width="1879" height="364" key="GridCell.Tab.0.right" timestamp="1617373756802"> <state width="1879" height="364" key="GridCell.Tab.0.right" timestamp="1617385468327">
<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="1617373756802" /> <state width="1879" height="364" key="GridCell.Tab.0.right/0.0.1920.1080@0.0.1920.1080" timestamp="1617385468327" />
<state width="1879" height="364" key="GridCell.Tab.1.bottom" timestamp="1617373756803"> <state width="1879" height="364" key="GridCell.Tab.1.bottom" timestamp="1617385468328">
<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.bottom/0.0.1920.1080@0.0.1920.1080" timestamp="1617373756803" /> <state width="1879" height="364" key="GridCell.Tab.1.bottom/0.0.1920.1080@0.0.1920.1080" timestamp="1617385468328" />
<state width="1879" height="364" key="GridCell.Tab.1.center" timestamp="1617373756802"> <state width="1879" height="364" key="GridCell.Tab.1.center" timestamp="1617385468328">
<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.center/0.0.1920.1080@0.0.1920.1080" timestamp="1617373756802" /> <state width="1879" height="364" key="GridCell.Tab.1.center/0.0.1920.1080@0.0.1920.1080" timestamp="1617385468328" />
<state width="1879" height="364" key="GridCell.Tab.1.left" timestamp="1617373756802"> <state width="1879" height="364" key="GridCell.Tab.1.left" timestamp="1617385468328">
<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.left/0.0.1920.1080@0.0.1920.1080" timestamp="1617373756802" /> <state width="1879" height="364" key="GridCell.Tab.1.left/0.0.1920.1080@0.0.1920.1080" timestamp="1617385468328" />
<state width="1879" height="364" key="GridCell.Tab.1.right" timestamp="1617373756802"> <state width="1879" height="364" key="GridCell.Tab.1.right" timestamp="1617385468328">
<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="1617373756802" /> <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="1617372800402"> <state x="0" y="0" key="com.intellij.ide.util.TipDialog" timestamp="1617383739858">
<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="1617372800402" /> <state x="0" y="0" key="com.intellij.ide.util.TipDialog/0.0.1920.1080@0.0.1920.1080" timestamp="1617383739858" />
</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="1617373729734" 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="1617385384539" 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>

View File

@ -1,6 +1,6 @@
import os import os
import pygame import pygame
BLOCK_SIZE = 100 BLOCK_SIZE = 60
BEETROOTS_GROW_TIME = 5 BEETROOTS_GROW_TIME = 5
BEETROOTS_MAXIMUM_STATE = BEETROOTS_GROW_TIME * 3 + 1 BEETROOTS_MAXIMUM_STATE = BEETROOTS_GROW_TIME * 3 + 1
BEETROOTS_STAGE_0 = pygame.image.load(os.path.join('resources', 'beetroots_stage_0.png')) BEETROOTS_STAGE_0 = pygame.image.load(os.path.join('resources', 'beetroots_stage_0.png'))
@ -23,6 +23,8 @@ CARROTS_STAGE_3 = pygame.image.load(os.path.join('resources', 'carrots_stage_3.p
CARROTS_STAGE_3 = pygame.transform.scale(CARROTS_STAGE_3, (BLOCK_SIZE, BLOCK_SIZE)) CARROTS_STAGE_3 = pygame.transform.scale(CARROTS_STAGE_3, (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))
HEIGHT_AMOUNT, WIDTH_AMOUNT = 10, 10
HEIGHT, WIDTH = BLOCK_SIZE * HEIGHT_AMOUNT, BLOCK_SIZE * WIDTH_AMOUNT
FARMLAND_DRY = pygame.image.load(os.path.join('resources', 'farmland_dry.png')) FARMLAND_DRY = pygame.image.load(os.path.join('resources', 'farmland_dry.png'))
FARMLAND_DRY = pygame.transform.scale(FARMLAND_DRY, (BLOCK_SIZE, BLOCK_SIZE)) FARMLAND_DRY = pygame.transform.scale(FARMLAND_DRY, (BLOCK_SIZE, BLOCK_SIZE))
FARMLAND_WET = pygame.image.load(os.path.join('resources', 'farmland_wet.png')) FARMLAND_WET = pygame.image.load(os.path.join('resources', 'farmland_wet.png'))
@ -38,7 +40,6 @@ POTATOES_STAGE_2 = pygame.image.load(os.path.join('resources', 'potatoes_stage_2
POTATOES_STAGE_2 = pygame.transform.scale(POTATOES_STAGE_2, (BLOCK_SIZE, BLOCK_SIZE)) POTATOES_STAGE_2 = pygame.transform.scale(POTATOES_STAGE_2, (BLOCK_SIZE, BLOCK_SIZE))
POTATOES_STAGE_3 = pygame.image.load(os.path.join('resources', 'potatoes_stage_3.png')) POTATOES_STAGE_3 = pygame.image.load(os.path.join('resources', 'potatoes_stage_3.png'))
POTATOES_STAGE_3 = pygame.transform.scale(POTATOES_STAGE_3, (BLOCK_SIZE, BLOCK_SIZE)) POTATOES_STAGE_3 = pygame.transform.scale(POTATOES_STAGE_3, (BLOCK_SIZE, BLOCK_SIZE))
WIDTH, HEIGHT = 1000, 1000
WINDOW = pygame.display.set_mode((WIDTH, HEIGHT)) WINDOW = pygame.display.set_mode((WIDTH, HEIGHT))
TRACTOR = pygame.image.load(os.path.join('resources', 'minecart_command_block.png')) TRACTOR = pygame.image.load(os.path.join('resources', 'minecart_command_block.png'))
TRACTOR = pygame.transform.scale(TRACTOR, (BLOCK_SIZE, BLOCK_SIZE)) TRACTOR = pygame.transform.scale(TRACTOR, (BLOCK_SIZE, BLOCK_SIZE))

16
py.py
View File

@ -8,9 +8,9 @@ import tractor
pygame.display.set_caption("Smart Tractor") pygame.display.set_caption("Smart Tractor")
fields = [] fields = []
def create_base_map(): def create_base_map():
for i in range(10): for i in range(definitions.WIDTH_AMOUNT):
temp_map_field = [] temp_map_field = []
for j in range(10): for j in range(definitions.HEIGHT_AMOUNT):
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(False, False, False) temp_soil = soil.Soil(False, False, False)
temp_plant = plant.Plant("none", 0) temp_plant = plant.Plant("none", 0)
@ -18,8 +18,8 @@ def create_base_map():
temp_map_field.append(temp_field) temp_map_field.append(temp_field)
fields.append(temp_map_field) fields.append(temp_map_field)
def fill_map(): def fill_map():
for i in range(10): for i in range(definitions.WIDTH_AMOUNT):
for j in range(10): for j in range(definitions.HEIGHT_AMOUNT):
field = fields[i][j] field = fields[i][j]
rect = field.get_rect() rect = field.get_rect()
if field.get_plant().get_name() == "beetroot" and field.get_plant().get_state() > 0 and field.get_plant().get_state() <= 1 * definitions.BEETROOTS_GROW_TIME: if field.get_plant().get_name() == "beetroot" and field.get_plant().get_state() > 0 and field.get_plant().get_state() <= 1 * definitions.BEETROOTS_GROW_TIME:
@ -75,8 +75,8 @@ def do_work(tractor1, tractor1_rect):
loop = True loop = True
if tractor1.get_all_amount_of_seeds() == 0: if tractor1.get_all_amount_of_seeds() == 0:
loop = False loop = False
x = int(tractor1_rect.x / 100) x = int(tractor1_rect.x / definitions.BLOCK_SIZE)
y = int(tractor1_rect.y / 100) y = int(tractor1_rect.y / definitions.BLOCK_SIZE)
field = fields[x][y] field = fields[x][y]
if field.get_soil().get_state() is False: if field.get_soil().get_state() is False:
field.get_soil().set_state(True) field.get_soil().set_state(True)
@ -151,8 +151,8 @@ def draw_window(tractor1_rect):
definitions.WINDOW.blit(definitions.TRACTOR, (tractor1_rect.x, tractor1_rect.y)) definitions.WINDOW.blit(definitions.TRACTOR, (tractor1_rect.x, tractor1_rect.y))
pygame.display.update() pygame.display.update()
def grow_plants(): def grow_plants():
for i in range(10): for i in range(definitions.WIDTH_AMOUNT):
for j in range(10): for j in range(definitions.HEIGHT_AMOUNT):
field = fields[i][j] field = fields[i][j]
if field.get_plant().get_name() == "beetroot" and field.get_plant().get_state() > 0 and field.get_plant().get_state() < definitions.BEETROOTS_MAXIMUM_STATE: if field.get_plant().get_name() == "beetroot" and field.get_plant().get_state() > 0 and field.get_plant().get_state() < definitions.BEETROOTS_MAXIMUM_STATE:
field.get_plant().set_state(field.get_plant().get_state() + 1) field.get_plant().set_state(field.get_plant().get_state() + 1)