emil merguj

This commit is contained in:
Tomasz Adamczyk 2021-03-21 14:10:08 +01:00
parent c673c5b201
commit d368ca0cd1
8 changed files with 46 additions and 26 deletions

View File

@ -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$/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" />
<change beforePath="$PROJECT_DIR$/resources/tractor.png" beforeDir="false" afterPath="$PROJECT_DIR$/resources/tractor.png" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -82,7 +81,7 @@
<workItem from="1615670854240" duration="68000" />
<workItem from="1616276134469" duration="1463000" />
<workItem from="1616322081205" duration="4362000" />
<workItem from="1616327331805" duration="3149000" />
<workItem from="1616327331805" duration="4731000" />
</task>
<servers />
</component>
@ -90,22 +89,22 @@
<option name="version" value="1" />
</component>
<component name="WindowStateProjectService">
<state width="1879" height="295" key="GridCell.Tab.0.bottom" timestamp="1616330562501">
<state width="1879" height="295" key="GridCell.Tab.0.bottom" timestamp="1616331755288">
<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="1616330562501" />
<state width="1879" height="295" key="GridCell.Tab.0.center" timestamp="1616330562501">
<state width="1879" height="295" key="GridCell.Tab.0.bottom/0.0.1920.1080@0.0.1920.1080" timestamp="1616331755288" />
<state width="1879" height="295" key="GridCell.Tab.0.center" timestamp="1616331755288">
<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="1616330562501" />
<state width="1879" height="295" key="GridCell.Tab.0.left" timestamp="1616330562501">
<state width="1879" height="295" key="GridCell.Tab.0.center/0.0.1920.1080@0.0.1920.1080" timestamp="1616331755288" />
<state width="1879" height="295" key="GridCell.Tab.0.left" timestamp="1616331755287">
<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="1616330562501" />
<state width="1879" height="295" key="GridCell.Tab.0.right" timestamp="1616330562501">
<state width="1879" height="295" key="GridCell.Tab.0.left/0.0.1920.1080@0.0.1920.1080" timestamp="1616331755287" />
<state width="1879" height="295" key="GridCell.Tab.0.right" timestamp="1616331755288">
<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="1616330562501" />
<state width="1879" height="295" key="GridCell.Tab.0.right/0.0.1920.1080@0.0.1920.1080" timestamp="1616331755288" />
<state width="1879" height="364" key="GridCell.Tab.1.bottom" timestamp="1616326478876">
<screen x="0" y="0" width="1920" height="1080" />
</state>
@ -128,6 +127,6 @@
<state x="0" y="0" key="com.intellij.ide.util.TipDialog/0.0.1920.1080@0.0.1920.1080" timestamp="1616327335999" />
</component>
<component name="com.intellij.coverage.CoverageDataManagerImpl">
<SUITE FILE_PATH="coverage/SmartTractor$py.coverage" NAME="py Coverage Results" MODIFIED="1616330562494" 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="1616331755279" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
</component>
</project>

View File

@ -1,5 +1,8 @@
import os
import pygame
BLOCK_SIZE = 100
DIRT = pygame.image.load(os.path.join('resources', 'dirt.png'))
DIRT = pygame.transform.scale(DIRT, (BLOCK_SIZE, BLOCK_SIZE))
FPS = 1
MAXIMUM_WATER_LEVEL = 100
WHITE = ((255, 255, 255))
@ -10,4 +13,6 @@ TRACTOR_WIDTH, TRACTOR_HEIGHT = 100, 100
TRACTOR = pygame.transform.scale(TRACTOR, (TRACTOR_WIDTH, TRACTOR_HEIGHT))
VEL = 100
WHEAT_MAXIMUM_STATE = 5
WHEAT_REQUIRED_WATER_LEVEL = 40
WHEAT_REQUIRED_WATER_LEVEL = 40
FARMLAND = pygame.image.load(os.path.join('resources', 'farmland.png'))
FARMLAND = pygame.transform.scale(DIRT, (BLOCK_SIZE, BLOCK_SIZE))

42
py.py
View File

@ -6,8 +6,23 @@ import random
import soil
import tractor
pygame.display.set_caption("Smart Tractor")
map_field = []
map_field_type = []
def create_base_map():
for i in range(10):
temp_map_field = []
temp_map_field_type = []
map_field.append(temp_map_field)
map_field_type.append(temp_map_field_type)
for j in range(10):
temp_map_field.append(pygame.Rect(i * definitions.BLOCK_SIZE, j * definitions.BLOCK_SIZE, definitions.BLOCK_SIZE, definitions.BLOCK_SIZE))
temp_map_field_type.append(definitions.DIRT)
def fill_map():
for i in range(10):
for j in range(10):
definitions.WIN.blit(map_field_type[i][j], (map_field[i][j].x, map_field[i][j].y))
def draw_window(tractor1_rectangle):
definitions.WIN.fill(definitions.WHITE)
fill_map()
definitions.WIN.blit(definitions.TRACTOR, (tractor1_rectangle.x, tractor1_rectangle.y))
pygame.display.update()
def is_move_allowed(move, tractor1_rectangle):
@ -40,18 +55,19 @@ def tractor1_handle_movement(tractor1, tractor1_rectangle):
tractor1_rectangle.x = tractor1.get_x()
tractor1_rectangle.y = tractor1.get_y()
def main():
fields = []
a = 0
b = 0
for i in range(100):
plant1 = plant.Plant(1, definitions.WHEAT_MAXIMUM_STATE, "Wheat", "None", definitions.WHEAT_REQUIRED_WATER_LEVEL)
soil1 = soil.Soil(True, definitions.MAXIMUM_WATER_LEVEL)
if (a > definitions.WIDTH - definitions.VEL):
a = 0
b = b + definitions.VEL
field1 = field.Field(a, b, plant1, soil1)
a = a + definitions.VEL;
fields.append(field1)
# fields = []
# a = 0
# b = 0
# for i in range(100):
# plant1 = plant.Plant(1, definitions.WHEAT_MAXIMUM_STATE, "Wheat", "None", definitions.WHEAT_REQUIRED_WATER_LEVEL)
# soil1 = soil.Soil(True, definitions.MAXIMUM_WATER_LEVEL)
# if (a > definitions.WIDTH - definitions.VEL):
# a = 0
# b = b + definitions.VEL
# field1 = field.Field(a, b, plant1, soil1)
# a = a + definitions.VEL;
# fields.append(field1)
create_base_map()
tractor1 = tractor.Tractor(400, 400)
tractor1_rectangle = pygame.Rect(tractor1.get_x(), tractor1.get_y(), definitions.TRACTOR_WIDTH, definitions.TRACTOR_HEIGHT)
clock = pygame.time.Clock()

BIN
resources/dirt.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 266 B

BIN
resources/farmland.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 258 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 610 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 131 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB