Wizualizacja kelnera i stolikow

This commit is contained in:
Arkadiusz 2019-03-19 23:36:06 +01:00
parent 0a27c0c00e
commit 8844adaaa0
15 changed files with 414 additions and 0 deletions

11
.idea/Test.iml Normal file
View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
<component name="TestRunnerService">
<option name="PROJECT_TEST_RUNNER" value="Unittests" />
</component>
</module>

4
.idea/encodings.xml Normal file
View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" addBOMForNewFiles="with NO BOM" />
</project>

4
.idea/misc.xml Normal file
View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.7" project-jdk-type="Python SDK" />
</project>

8
.idea/modules.xml Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/Test.iml" filepath="$PROJECT_DIR$/.idea/Test.iml" />
</modules>
</component>
</project>

281
.idea/workspace.xml Normal file
View File

@ -0,0 +1,281 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="152ea650-8e02-4ed6-aa8c-04d44b275be4" name="Default Changelist" comment="" />
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="FileEditorManager">
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/table.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="289">
<caret line="17" column="9" selection-start-line="17" selection-start-column="9" selection-end-line="17" selection-end-column="9" />
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/waiter.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="272">
<caret line="16" column="19" lean-forward="true" selection-start-line="16" selection-start-column="19" selection-end-line="16" selection-end-column="19" />
<folding>
<element signature="e#0#13#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/run.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="510">
<caret line="30" column="23" lean-forward="true" selection-start-line="30" selection-start-column="23" selection-end-line="30" selection-end-column="23" />
<folding>
<element signature="e#0#18#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$USER_HOME$/Desktop/pygame-elsa/elsa_gra.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="316">
<caret line="66" column="32" selection-start-line="66" selection-start-column="17" selection-end-line="66" selection-end-column="32" />
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="true">
<entry file="file://$USER_HOME$/Desktop/pygame-elsa/sprites/elsa.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="238">
<caret line="15" lean-forward="true" selection-start-line="15" selection-end-line="15" />
</state>
</provider>
</entry>
</file>
</leaf>
</component>
<component name="FileTemplateManagerImpl">
<option name="RECENT_TEMPLATES">
<list>
<option value="Python Script" />
</list>
</option>
</component>
<component name="IdeDocumentHistory">
<option name="CHANGED_PATHS">
<list>
<option value="$PROJECT_DIR$/1" />
<option value="$PROJECT_DIR$/run.py" />
<option value="$PROJECT_DIR$/table.py" />
<option value="$PROJECT_DIR$/waiter.py" />
</list>
</option>
</component>
<component name="ProjectFrameBounds" extendedState="6">
<option name="x" value="260" />
<option name="y" value="20" />
<option name="width" value="1400" />
<option name="height" value="1000" />
</component>
<component name="ProjectView">
<navigator proportions="" version="1">
<foldersAlwaysOnTop value="true" />
</navigator>
<panes>
<pane id="ProjectPane">
<subPane>
<expand>
<path>
<item name="Test" type="b2602c69:ProjectViewProjectNode" />
<item name="Test" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="Test" type="b2602c69:ProjectViewProjectNode" />
<item name="Test" type="462c0819:PsiDirectoryNode" />
<item name="Images" type="462c0819:PsiDirectoryNode" />
</path>
</expand>
<select />
</subPane>
</pane>
<pane id="Scope" />
</panes>
</component>
<component name="PropertiesComponent">
<property name="last_opened_file_path" value="$PROJECT_DIR$" />
<property name="settings.editor.selected.configurable" value="com.jetbrains.python.configuration.PyActiveSdkModuleConfigurable" />
</component>
<component name="RecentsManager">
<key name="MoveFile.RECENT_KEYS">
<recent name="C:\Users\user\PycharmProjects\Test\Images" />
</key>
</component>
<component name="RunDashboard">
<option name="ruleStates">
<list>
<RuleState>
<option name="name" value="ConfigurationTypeDashboardGroupingRule" />
</RuleState>
<RuleState>
<option name="name" value="StatusDashboardGroupingRule" />
</RuleState>
</list>
</option>
</component>
<component name="RunManager">
<configuration name="1" type="PythonConfigurationType" factoryName="Python" temporary="true">
<module name="Test" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<envs>
<env name="PYTHONUNBUFFERED" value="1" />
</envs>
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/run.py" />
<option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" />
<option name="MODULE_MODE" value="false" />
<option name="REDIRECT_INPUT" value="false" />
<option name="INPUT_FILE" value="" />
<method v="2" />
</configuration>
<recent_temporary>
<list>
<item itemvalue="Python.1" />
</list>
</recent_temporary>
</component>
<component name="SvnConfiguration">
<configuration />
</component>
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="152ea650-8e02-4ed6-aa8c-04d44b275be4" name="Default Changelist" comment="" />
<created>1552504215314</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1552504215314</updated>
</task>
<servers />
</component>
<component name="TodoView">
<todo-panel id="selected-file">
<is-autoscroll-to-source value="true" />
</todo-panel>
<todo-panel id="all">
<are-packages-shown value="true" />
<is-autoscroll-to-source value="true" />
</todo-panel>
</component>
<component name="ToolWindowManager">
<frame x="-8" y="-8" width="1936" height="1056" extended-state="6" />
<editor active="true" />
<layout>
<window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.17913593" />
<window_info id="Structure" order="1" side_tool="true" weight="0.25" />
<window_info id="Favorites" order="2" side_tool="true" />
<window_info anchor="bottom" id="Message" order="0" />
<window_info anchor="bottom" id="Find" order="1" />
<window_info anchor="bottom" id="Run" order="2" sideWeight="0.49947312" weight="0.32936078" />
<window_info anchor="bottom" id="Debug" order="3" weight="0.3997833" />
<window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
<window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
<window_info anchor="bottom" id="TODO" order="6" weight="0.32936078" />
<window_info anchor="bottom" id="Version Control" order="7" />
<window_info anchor="bottom" id="Terminal" order="8" />
<window_info anchor="bottom" id="Event Log" order="9" sideWeight="0.50052685" side_tool="true" weight="0.30985916" />
<window_info anchor="bottom" id="Python Console" order="10" />
<window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
<window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
<window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
</layout>
</component>
<component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/1">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="17">
<caret line="1" column="8" selection-start-line="1" selection-start-column="8" selection-end-line="1" selection-end-column="8" />
</state>
</provider>
</entry>
<entry file="file://$USER_HOME$/Desktop/pygame-elsa/sprites/olaf.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="102">
<caret line="7" column="29" lean-forward="true" selection-start-line="7" selection-start-column="29" selection-end-line="7" selection-end-column="29" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/Images/waiter.jpg">
<provider selected="true" editor-type-id="images" />
</entry>
<entry file="file://$APPLICATION_HOME_DIR$/helpers/pydev/pydevd.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="168">
<caret line="1134" selection-start-line="1134" selection-end-line="1134" />
</state>
</provider>
</entry>
<entry file="file://$APPLICATION_HOME_DIR$/helpers/pydev/_pydev_imps/_pydev_execfile.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="289">
<caret line="17" selection-start-line="17" selection-end-line="17" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/table.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="289">
<caret line="17" column="9" selection-start-line="17" selection-start-column="9" selection-end-line="17" selection-end-column="9" />
</state>
</provider>
</entry>
<entry file="file://$USER_HOME$/Desktop/pygame-elsa/elsa_gra.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="316">
<caret line="66" column="32" selection-start-line="66" selection-start-column="17" selection-end-line="66" selection-end-column="32" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/run.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="510">
<caret line="30" column="23" lean-forward="true" selection-start-line="30" selection-start-column="23" selection-end-line="30" selection-end-column="23" />
<folding>
<element signature="e#0#18#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/waiter.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="272">
<caret line="16" column="19" lean-forward="true" selection-start-line="16" selection-start-column="19" selection-end-line="16" selection-end-column="19" />
<folding>
<element signature="e#0#13#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$USER_HOME$/Desktop/pygame-elsa/sprites/elsa.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="238">
<caret line="15" lean-forward="true" selection-start-line="15" selection-end-line="15" />
</state>
</provider>
</entry>
</component>
</project>

2
1 Normal file
View File

@ -0,0 +1,2 @@
i =3
print(i)

BIN
Images/tableSmall.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

BIN
Images/tlo.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 552 KiB

BIN
Images/w1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.5 KiB

BIN
Images/waiter.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

Binary file not shown.

54
run.py Normal file
View File

@ -0,0 +1,54 @@
import pygame, sys
from waiter import Waiter
from table import Table
class Game(object):
def __init__(self):
pygame.init()
self.screen = pygame.display.set_mode((1000, 900))
self.fpsClock = pygame.time.Clock()
self.idTable = 0
pygame.display.set_caption('Automatic Waiter')
self.background = pygame.image.load("./Images/tlo.jpg")
self.waiter = Waiter(self)
self.tables = [Table(50, 50, self), Table(400, 50, self), Table(750, 50, self), Table(50, 450, self), Table(400, 450, self), Table(750, 450, self)]
for t in self.tables:
print(t.id)
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
sys.exit(0)
#self.screen.fill((0, 0, 0))
self.screen.blit(self.background, (0, 0))
self.draw()
self.waiter.move()
pygame.display.flip()
self.fpsClock.tick(10)
def draw(self):
self.waiter.draw()
for table in self.tables:
table.draw()
if __name__ == "__main__":
Game()

19
table.py Normal file
View File

@ -0,0 +1,19 @@
import pygame
class Table(object):
def __init__(self, x, y, game, height=2, width=4):
self.x = x
self.y = y
self.height = height
self.width = width
self.game = game
game.idTable += 1
self.isBusy = False
self.id = game.idTable
self.image = pygame.image.load("./Images/tableSmall.png")
def draw(self):
table = pygame.Rect(self.x, self.y, 50 * self.width, 50 * self.height)
#pygame.draw.rect(self.game.screen, (100, 0, 100,), table)
self.game.screen.blit(self.image, (self.x, self.y))

31
waiter.py Normal file
View File

@ -0,0 +1,31 @@
import pygame
from pygame.math import Vector2
class Waiter(object):
def __init__(self, game):
self.game = game
self.size= self.game.screen.get_size()
self.position = Vector2(self.size[0]-100,self.size[1]-200)
self.image = pygame.image.load("./Images/w1.png").convert()
self.image.set_colorkey((255, 255, 255))
def changePosition(self, vector):
self.position += vector
def move(self):
keys = pygame.key.get_pressed()
if keys[pygame.K_DOWN]:
self.changePosition(Vector2(0,50))
if keys[pygame.K_UP]:
self.changePosition(Vector2(0,-50))
if keys[pygame.K_RIGHT]:
self.changePosition(Vector2(50,0))
if keys[pygame.K_LEFT]:
self.changePosition(Vector2(-50,0))
def draw(self):
rect1 = pygame.Rect(self.position.x, self.position.y, 100, 200)
#pygame.draw.rect(self.game.screen, (0, 150, 255), rect1)
self.game.screen.blit(self.image, (self.position.x, self.position.y))