pola wypełnione danymi
This commit is contained in:
parent
d368ca0cd1
commit
37cbaed6d3
@ -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$/field.py" beforeDir="false" afterPath="$PROJECT_DIR$/field.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$/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" />
|
||||
@ -81,7 +82,7 @@
|
||||
<workItem from="1615670854240" duration="68000" />
|
||||
<workItem from="1616276134469" duration="1463000" />
|
||||
<workItem from="1616322081205" duration="4362000" />
|
||||
<workItem from="1616327331805" duration="4731000" />
|
||||
<workItem from="1616327331805" duration="7576000" />
|
||||
</task>
|
||||
<servers />
|
||||
</component>
|
||||
@ -89,22 +90,22 @@
|
||||
<option name="version" value="1" />
|
||||
</component>
|
||||
<component name="WindowStateProjectService">
|
||||
<state width="1879" height="295" key="GridCell.Tab.0.bottom" timestamp="1616331755288">
|
||||
<state width="1879" height="295" key="GridCell.Tab.0.bottom" timestamp="1616336008541">
|
||||
<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="1616331755288" />
|
||||
<state width="1879" height="295" key="GridCell.Tab.0.center" timestamp="1616331755288">
|
||||
<state width="1879" height="295" key="GridCell.Tab.0.bottom/0.0.1920.1080@0.0.1920.1080" timestamp="1616336008541" />
|
||||
<state width="1879" height="295" key="GridCell.Tab.0.center" timestamp="1616336008541">
|
||||
<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="1616331755288" />
|
||||
<state width="1879" height="295" key="GridCell.Tab.0.left" timestamp="1616331755287">
|
||||
<state width="1879" height="295" key="GridCell.Tab.0.center/0.0.1920.1080@0.0.1920.1080" timestamp="1616336008541" />
|
||||
<state width="1879" height="295" key="GridCell.Tab.0.left" timestamp="1616336008541">
|
||||
<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="1616331755287" />
|
||||
<state width="1879" height="295" key="GridCell.Tab.0.right" timestamp="1616331755288">
|
||||
<state width="1879" height="295" key="GridCell.Tab.0.left/0.0.1920.1080@0.0.1920.1080" timestamp="1616336008541" />
|
||||
<state width="1879" height="295" key="GridCell.Tab.0.right" timestamp="1616336008541">
|
||||
<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="1616331755288" />
|
||||
<state width="1879" height="295" key="GridCell.Tab.0.right/0.0.1920.1080@0.0.1920.1080" timestamp="1616336008541" />
|
||||
<state width="1879" height="364" key="GridCell.Tab.1.bottom" timestamp="1616326478876">
|
||||
<screen x="0" y="0" width="1920" height="1080" />
|
||||
</state>
|
||||
@ -127,6 +128,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="1616331755279" 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="1616335958059" 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.
Binary file not shown.
Binary file not shown.
@ -3,16 +3,12 @@ import pygame
|
||||
BLOCK_SIZE = 100
|
||||
DIRT = pygame.image.load(os.path.join('resources', 'dirt.png'))
|
||||
DIRT = pygame.transform.scale(DIRT, (BLOCK_SIZE, BLOCK_SIZE))
|
||||
FARMLAND = pygame.image.load(os.path.join('resources', 'farmland.png'))
|
||||
FARMLAND = pygame.transform.scale(FARMLAND, (BLOCK_SIZE, BLOCK_SIZE))
|
||||
FPS = 1
|
||||
MAXIMUM_WATER_LEVEL = 100
|
||||
WHITE = ((255, 255, 255))
|
||||
WIDTH, HEIGHT = 1000, 1000
|
||||
WIN = pygame.display.set_mode((WIDTH, HEIGHT))
|
||||
TRACTOR = pygame.image.load(os.path.join('resources', 'tractor.png'))
|
||||
TRACTOR_WIDTH, TRACTOR_HEIGHT = 100, 100
|
||||
TRACTOR = pygame.transform.scale(TRACTOR, (TRACTOR_WIDTH, TRACTOR_HEIGHT))
|
||||
TRACTOR = pygame.transform.scale(TRACTOR, (BLOCK_SIZE, BLOCK_SIZE))
|
||||
VEL = 100
|
||||
WHEAT_MAXIMUM_STATE = 5
|
||||
WHEAT_REQUIRED_WATER_LEVEL = 40
|
||||
FARMLAND = pygame.image.load(os.path.join('resources', 'farmland.png'))
|
||||
FARMLAND = pygame.transform.scale(DIRT, (BLOCK_SIZE, BLOCK_SIZE))
|
||||
WHEAT_MAXIMUM_STATE = 5
|
17
field.py
17
field.py
@ -1,21 +1,16 @@
|
||||
class Field:
|
||||
def __init__(self, x, y, plant, soil):
|
||||
self.x = x
|
||||
self.y = y
|
||||
def __init__(self, plant, rect, soil):
|
||||
self.plant = plant
|
||||
self.rect = rect
|
||||
self.soil = soil
|
||||
def get_x(self):
|
||||
return self.x
|
||||
def set_x(self, x):
|
||||
self.x = x
|
||||
def get_y(self):
|
||||
return self.y
|
||||
def set_y(self, y):
|
||||
self.y = y
|
||||
def get_plant(self):
|
||||
return self.plant
|
||||
def set_plant(self, plant):
|
||||
self.plant = plant
|
||||
def set_rect(self, rect):
|
||||
self.rect = rect
|
||||
def get_rect(self):
|
||||
return self.rect
|
||||
def get_soil(self):
|
||||
return self.soil
|
||||
def set_soil(self, soil):
|
||||
|
19
plant.py
19
plant.py
@ -1,10 +1,7 @@
|
||||
class Plant:
|
||||
def __init__(self, current_state, maximum_state, name, organic, required_water_level):
|
||||
def __init__(self, current_state, maximum_state):
|
||||
self.current_state = current_state
|
||||
self.maximum_state = maximum_state
|
||||
self.name = name
|
||||
self.organic = organic
|
||||
self.required_water_level = required_water_level
|
||||
def get_current_state(self):
|
||||
return self.current_state
|
||||
def set_current_state(self, current_state):
|
||||
@ -12,16 +9,4 @@ class Plant:
|
||||
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):
|
||||
return self.name
|
||||
def set_name(self, name):
|
||||
self.name = name
|
||||
def get_organic(self):
|
||||
return self.organic
|
||||
def set_organic(self, organic):
|
||||
self.organic = organic
|
||||
def get_required_water_level(self):
|
||||
return self.required_water_level
|
||||
def set_required_water_level(self, required_water_level):
|
||||
self.required_water_level = required_water_level
|
||||
self.maximum_state = maximum_state
|
38
py.py
38
py.py
@ -6,31 +6,35 @@ import random
|
||||
import soil
|
||||
import tractor
|
||||
pygame.display.set_caption("Smart Tractor")
|
||||
map_field = []
|
||||
map_field_type = []
|
||||
fields = []
|
||||
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)
|
||||
temp_rect = pygame.Rect(i * definitions.BLOCK_SIZE, j * definitions.BLOCK_SIZE, definitions.BLOCK_SIZE, definitions.BLOCK_SIZE)
|
||||
temp_soil = soil.Soil(False, False)
|
||||
temp_plant = plant.Plant(0, definitions.WHEAT_MAXIMUM_STATE)
|
||||
temp_field = field.Field(temp_plant, temp_rect, temp_soil)
|
||||
temp_map_field.append(temp_field)
|
||||
fields.append(temp_map_field)
|
||||
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))
|
||||
field = fields[i][j]
|
||||
rect = field.get_rect()
|
||||
if field.get_soil().get_state() == False:
|
||||
block = definitions.DIRT
|
||||
definitions.WIN.blit(block, (rect.x, rect.y))
|
||||
def draw_window(tractor1_rectangle):
|
||||
fill_map()
|
||||
definitions.WIN.blit(definitions.TRACTOR, (tractor1_rectangle.x, tractor1_rectangle.y))
|
||||
pygame.display.update()
|
||||
def is_move_allowed(move, tractor1_rectangle):
|
||||
if ((move == 1) and (tractor1_rectangle.y + definitions.VEL + definitions.TRACTOR_HEIGHT <= definitions.HEIGHT)):
|
||||
if ((move == 1) and (tractor1_rectangle.y + definitions.VEL + definitions.BLOCK_SIZE <= 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)):
|
||||
elif ((move == 3) and (tractor1_rectangle.x + definitions.VEL + definitions.BLOCK_SIZE <= definitions.WIDTH)):
|
||||
return True
|
||||
elif ((move == 4) and (tractor1_rectangle.y - definitions.VEL >= 0)):
|
||||
return True
|
||||
@ -55,21 +59,9 @@ 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)
|
||||
create_base_map()
|
||||
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.BLOCK_SIZE, definitions.BLOCK_SIZE)
|
||||
clock = pygame.time.Clock()
|
||||
run = True
|
||||
while run:
|
||||
|
Loading…
Reference in New Issue
Block a user