wypełnione pola roślinami

This commit is contained in:
Tomasz Adamczyk 2021-03-21 13:45:20 +01:00
parent d8cf576ddf
commit c673c5b201
10 changed files with 45 additions and 32 deletions

View File

@ -3,7 +3,10 @@
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="56453584-72bd-49f4-a39c-fccf91ab20c6" name="Default Changelist" comment=""> <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$/.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$/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> </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" />
@ -79,7 +82,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" /> <workItem from="1616327331805" duration="3149000" />
</task> </task>
<servers /> <servers />
</component> </component>
@ -87,22 +90,22 @@
<option name="version" value="1" /> <option name="version" value="1" />
</component> </component>
<component name="WindowStateProjectService"> <component name="WindowStateProjectService">
<state width="1879" height="295" key="GridCell.Tab.0.bottom" timestamp="1616327942000"> <state width="1879" height="295" key="GridCell.Tab.0.bottom" timestamp="1616330562501">
<screen x="0" y="0" width="1920" height="1080" /> <screen x="0" y="0" width="1920" height="1080" />
</state> </state>
<state width="1879" height="295" key="GridCell.Tab.0.bottom/0.0.1920.1080@0.0.1920.1080" timestamp="1616327942000" /> <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="1616327942000"> <state width="1879" height="295" key="GridCell.Tab.0.center" timestamp="1616330562501">
<screen x="0" y="0" width="1920" height="1080" /> <screen x="0" y="0" width="1920" height="1080" />
</state> </state>
<state width="1879" height="295" key="GridCell.Tab.0.center/0.0.1920.1080@0.0.1920.1080" timestamp="1616327942000" /> <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="1616327942000"> <state width="1879" height="295" key="GridCell.Tab.0.left" timestamp="1616330562501">
<screen x="0" y="0" width="1920" height="1080" /> <screen x="0" y="0" width="1920" height="1080" />
</state> </state>
<state width="1879" height="295" key="GridCell.Tab.0.left/0.0.1920.1080@0.0.1920.1080" timestamp="1616327942000" /> <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="1616327942000"> <state width="1879" height="295" key="GridCell.Tab.0.right" timestamp="1616330562501">
<screen x="0" y="0" width="1920" height="1080" /> <screen x="0" y="0" width="1920" height="1080" />
</state> </state>
<state width="1879" height="295" key="GridCell.Tab.0.right/0.0.1920.1080@0.0.1920.1080" timestamp="1616327942000" /> <state width="1879" height="295" key="GridCell.Tab.0.right/0.0.1920.1080@0.0.1920.1080" timestamp="1616330562501" />
<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>
@ -125,6 +128,6 @@
<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="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="1616327941991" 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="1616330562494" 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.

Binary file not shown.

Binary file not shown.

View File

@ -1,6 +1,7 @@
import os import os
import pygame import pygame
FPS = 1 FPS = 1
MAXIMUM_WATER_LEVEL = 100
WHITE = ((255, 255, 255)) WHITE = ((255, 255, 255))
WIDTH, HEIGHT = 1000, 1000 WIDTH, HEIGHT = 1000, 1000
WIN = pygame.display.set_mode((WIDTH, HEIGHT)) WIN = pygame.display.set_mode((WIDTH, HEIGHT))
@ -8,3 +9,5 @@ TRACTOR = pygame.image.load(os.path.join('resources', 'tractor.png'))
TRACTOR_WIDTH, TRACTOR_HEIGHT = 100, 100 TRACTOR_WIDTH, TRACTOR_HEIGHT = 100, 100
TRACTOR = pygame.transform.scale(TRACTOR, (TRACTOR_WIDTH, TRACTOR_HEIGHT)) TRACTOR = pygame.transform.scale(TRACTOR, (TRACTOR_WIDTH, TRACTOR_HEIGHT))
VEL = 100 VEL = 100
WHEAT_MAXIMUM_STATE = 5
WHEAT_REQUIRED_WATER_LEVEL = 40

View File

@ -1,10 +1,18 @@
class Plant: class Plant:
def __init__(self, name, organic, required_productivity, required_water_level, state): def __init__(self, current_state, maximum_state, name, organic, required_water_level):
self.current_state = current_state
self.maximum_state = maximum_state
self.name = name self.name = name
self.organic = organic self.organic = organic
self.required_productivity = required_productivity
self.required_water_level = required_water_level self.required_water_level = required_water_level
self.state = state def get_current_state(self):
return self.current_state
def set_current_state(self, current_state):
self.current_state = current_state
def get_maximum_state(self):
return self.maximum_state
def set_maximum_state(self, maximum_state):
self.maximum_state = maximum_state
def get_name(self): def get_name(self):
return self.name return self.name
def set_name(self, name): def set_name(self, name):
@ -13,15 +21,7 @@ class Plant:
return self.organic return self.organic
def set_organic(self, organic): def set_organic(self, organic):
self.organic = organic self.organic = organic
def get_required_productivity(self):
return self.required_productivity
def set_required_productivity(self, required_productivity):
self.required_productivity = required_productivity
def get_required_water_level(self): def get_required_water_level(self):
return self.required_water_level return self.required_water_level
def set_required_water_level(self, required_water_level): def set_required_water_level(self, required_water_level):
self.required_water_level = required_water_level self.required_water_level = required_water_level
def get_state(self):
return self.state
def set_state(self, state):
self.state = state

14
py.py
View File

@ -40,7 +40,19 @@ def tractor1_handle_movement(tractor1, tractor1_rectangle):
tractor1_rectangle.x = tractor1.get_x() tractor1_rectangle.x = tractor1.get_x()
tractor1_rectangle.y = tractor1.get_y() tractor1_rectangle.y = tractor1.get_y()
def main(): def main():
tractor1 = tractor.Tractor(0, 0) 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)
tractor1 = tractor.Tractor(400, 400)
tractor1_rectangle = pygame.Rect(tractor1.get_x(), tractor1.get_y(), definitions.TRACTOR_WIDTH, definitions.TRACTOR_HEIGHT) tractor1_rectangle = pygame.Rect(tractor1.get_x(), tractor1.get_y(), definitions.TRACTOR_WIDTH, definitions.TRACTOR_HEIGHT)
clock = pygame.time.Clock() clock = pygame.time.Clock()
run = True run = True

View File

@ -1,12 +1,7 @@
class Soil: class Soil:
def __init__(self, name, state, water_level): def __init__(self, state, water_level):
self.name = name
self.state = state self.state = state
self.water_level = water_level self.water_level = water_level
def get_name(self):
return self.name
def set_name(self, name):
self.name = name
def get_state(self): def get_state(self):
return self.state return self.state
def set_state(self, state): def set_state(self, state):

View File

@ -1,8 +1,8 @@
import definitions import definitions
class Tractor: class Tractor:
def __init__(self, x, y): def __init__(self, x, y):
self.x = x = 0 self.x = x
self.y = y = 0 self.y = y
def get_x(self): def get_x(self):
return self.x return self.x
def set_x(self, x): def set_x(self, x):