Lada i skromne kolizje

This commit is contained in:
Arkadiusz 2019-03-26 11:05:21 +01:00
parent 25c315b794
commit 7e82a52039
5 changed files with 101 additions and 50 deletions

View File

@ -1,8 +1,10 @@
<?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="Dodanie listy wszystkich elementow">
<list default="true" id="152ea650-8e02-4ed6-aa8c-04d44b275be4" name="Default Changelist" comment="">
<change afterPath="$PROJECT_DIR$/orderTable.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/gridElement.py" beforeDir="false" afterPath="$PROJECT_DIR$/gridElement.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/run.py" beforeDir="false" afterPath="$PROJECT_DIR$/run.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/waiter.py" beforeDir="false" afterPath="$PROJECT_DIR$/waiter.py" afterDir="false" />
</list>
@ -17,17 +19,17 @@
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/table.py">
<provider selected="true" editor-type-id="text-editor">
<state>
<caret column="13" lean-forward="true" selection-start-column="13" selection-end-column="13" />
<state relative-caret-position="238">
<caret line="14" column="27" lean-forward="true" selection-start-line="14" selection-start-column="27" selection-end-line="14" selection-end-column="27" />
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="true">
<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="221">
<caret line="25" column="16" selection-start-line="25" selection-start-column="16" selection-end-line="25" selection-end-column="16" />
<state relative-caret-position="-279">
<caret line="29" column="30" lean-forward="true" selection-start-line="29" selection-start-column="30" selection-end-line="29" selection-end-column="30" />
<folding>
<element signature="e#0#13#0" expanded="true" />
</folding>
@ -38,17 +40,17 @@
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/gridElement.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="221">
<caret line="13" column="50" selection-start-line="13" selection-start-column="50" selection-end-line="13" selection-end-column="50" />
<state relative-caret-position="102">
<caret line="6" column="17" lean-forward="true" selection-start-line="6" selection-start-column="17" selection-end-line="6" selection-end-column="17" />
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<file pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/run.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="112">
<caret line="58" column="12" lean-forward="true" selection-start-line="58" selection-start-column="12" selection-end-line="58" selection-end-column="12" />
<state relative-caret-position="535">
<caret line="73" column="21" selection-start-line="73" selection-start-column="21" selection-end-line="73" selection-end-column="21" />
<folding>
<element signature="e#0#18#0" expanded="true" />
</folding>
@ -59,7 +61,7 @@
<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="1020">
<state relative-caret-position="588">
<caret line="66" column="32" selection-start-line="66" selection-start-column="17" selection-end-line="66" selection-end-column="32" />
</state>
</provider>
@ -74,6 +76,15 @@
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/orderTable.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="153">
<caret line="9" column="45" selection-start-line="9" selection-start-column="45" selection-end-line="9" selection-end-column="45" />
</state>
</provider>
</entry>
</file>
</leaf>
</component>
<component name="FileTemplateManagerImpl">
@ -84,6 +95,11 @@
</option>
</component>
<component name="Git.Settings">
<option name="PREVIOUS_COMMIT_AUTHORS">
<list>
<option value="Arkadiusz &lt;arek.jurga8@gmail.com&gt;" />
</list>
</option>
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
<component name="IdeDocumentHistory">
@ -91,10 +107,11 @@
<list>
<option value="$PROJECT_DIR$/1" />
<option value="$PROJECT_DIR$/Images/order.py" />
<option value="$PROJECT_DIR$/gridElement.py" />
<option value="$PROJECT_DIR$/table.py" />
<option value="$PROJECT_DIR$/run.py" />
<option value="$PROJECT_DIR$/gridElement.py" />
<option value="$PROJECT_DIR$/orderTable.py" />
<option value="$PROJECT_DIR$/waiter.py" />
<option value="$PROJECT_DIR$/run.py" />
</list>
</option>
</component>
@ -206,7 +223,14 @@
<option name="project" value="LOCAL" />
<updated>1553122011220</updated>
</task>
<option name="localTasksCounter" value="3" />
<task id="LOCAL-00003" summary="Dodanie macierzy i pelne poruszanie">
<created>1553453836096</created>
<option name="number" value="00003" />
<option name="presentableId" value="LOCAL-00003" />
<option name="project" value="LOCAL" />
<updated>1553453836097</updated>
</task>
<option name="localTasksCounter" value="4" />
<servers />
</component>
<component name="TodoView">
@ -220,20 +244,19 @@
</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 active="true" anchor="bottom" id="Run" order="2" sideWeight="0.49894625" visible="true" weight="0.32936078" />
<window_info anchor="bottom" id="Run" order="2" sideWeight="0.49894625" 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" sideWeight="0.49947312" weight="0.32936078" />
<window_info anchor="bottom" id="Terminal" order="8" />
<window_info anchor="bottom" id="Terminal" order="8" weight="0.32936078" />
<window_info anchor="bottom" id="Event Log" order="9" sideWeight="0.50105375" side_tool="true" weight="0.32936078" />
<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" />
@ -244,7 +267,8 @@
<component name="VcsManagerConfiguration">
<MESSAGE value="Dodanie gridElement" />
<MESSAGE value="Dodanie listy wszystkich elementow" />
<option name="LAST_COMMIT_MESSAGE" value="Dodanie listy wszystkich elementow" />
<MESSAGE value="Dodanie macierzy i pelne poruszanie" />
<option name="LAST_COMMIT_MESSAGE" value="Dodanie macierzy i pelne poruszanie" />
</component>
<component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/1">
@ -281,13 +305,6 @@
<entry file="file://$PROJECT_DIR$/Images/tlo.jpg">
<provider selected="true" editor-type-id="images" />
</entry>
<entry file="file://$USER_HOME$/Desktop/pygame-elsa/elsa_gra.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="1020">
<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://$USER_HOME$/Desktop/pygame-elsa/sprites/elsa.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="357">
@ -305,39 +322,53 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/table.py">
<entry file="file://$USER_HOME$/Desktop/pygame-elsa/elsa_gra.py">
<provider selected="true" editor-type-id="text-editor">
<state>
<caret column="13" lean-forward="true" selection-start-column="13" selection-end-column="13" />
<state relative-caret-position="588">
<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$/orderTable.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="153">
<caret line="9" column="45" selection-start-line="9" selection-start-column="45" selection-end-line="9" selection-end-column="45" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/gridElement.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="221">
<caret line="13" column="50" selection-start-line="13" selection-start-column="50" selection-end-line="13" selection-end-column="50" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/run.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="112">
<caret line="58" column="12" lean-forward="true" selection-start-line="58" selection-start-column="12" selection-end-line="58" selection-end-column="12" />
<folding>
<element signature="e#0#18#0" expanded="true" />
</folding>
<state relative-caret-position="102">
<caret line="6" column="17" lean-forward="true" selection-start-line="6" selection-start-column="17" selection-end-line="6" selection-end-column="17" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/waiter.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="221">
<caret line="25" column="16" selection-start-line="25" selection-start-column="16" selection-end-line="25" selection-end-column="16" />
<state relative-caret-position="-279">
<caret line="29" column="30" lean-forward="true" selection-start-line="29" selection-start-column="30" selection-end-line="29" selection-end-column="30" />
<folding>
<element signature="e#0#13#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/table.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="238">
<caret line="14" column="27" lean-forward="true" selection-start-line="14" selection-start-column="27" selection-end-line="14" selection-end-column="27" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/run.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="535">
<caret line="73" column="21" selection-start-line="73" selection-start-column="21" selection-end-line="73" selection-end-column="21" />
<folding>
<element signature="e#0#18#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</component>
</project>

View File

@ -1,7 +1,7 @@
import pygame
class GridElement(object):
def __init__(self,x,y,game):
def __init__(self, x, y, game):
self.game = game
game.idItem += 1
self.number = game.idItem

18
orderTable.py Normal file
View File

@ -0,0 +1,18 @@
import pygame
class OrderTable(object):
def __init__(self, x, y, game):
self.game = game
game.idItem += 1
game.idOrderTable += 1
self.idItem = game.idItem
self.idOrderTable = game.idOrderTable
self.x = x
self.y = y
self.image = pygame.image.load("./Images/lada.png")
self.type = "orderTable"
def draw(self):
self.rect = pygame.Rect(self.x, self.y, 50, 50)
self.game.screen.blit(self.image,(self.x, self.y))

12
run.py
View File

@ -3,6 +3,7 @@ from waiter import Waiter
from table import Table
from gridElement import GridElement
from pygame.math import Vector2
from orderTable import OrderTable
class Game(object):
def __init__(self):
@ -14,6 +15,7 @@ class Game(object):
self.idTable = 0
self.idOrder = 0
self.idItem = -1
self.idOrderTable = 0
self.waiterNumberInGrid = Vector2()
pygame.display.set_caption('Automatic Waiter')
self.background = pygame.image.load("./Images/tlo.jpg")
@ -26,20 +28,18 @@ class Game(object):
for i in range(self.x):
if ((i == 0) or (i == 8) or (i == 16)) and ((b == 2) or (b == 8)):
self.row.append(Table(i * 50, b * 50, self))
elif b == self.y-1 and (i == 10 or i == 11 or i == 12 or i == 13 or i == 14 or i == 15):
self.row.append((OrderTable(i * 50, b * 50, self)))
elif i == 18 and b == 14:
self.row.append(Waiter(self, i * 50, b * 50))
self.waiterNumberInGrid.x = i
self.waiterNumberInGrid.y = b
else:
self.row.append(GridElement(i * 50, b * 50, self))
if i == 19:
self.grid.append(list(self.row))
self.row.clear()
self.showGrid(self.grid)
while True:
for event in pygame.event.get():
@ -49,7 +49,7 @@ class Game(object):
self.draw()
self.grid[int(self.waiterNumberInGrid.y)][int(self.waiterNumberInGrid.x)].move(self)
pygame.display.flip()
print(self.waiterNumberInGrid)
#print(self.waiterNumberInGrid)
self.fpsClock.tick(10)
def draw(self):
@ -70,6 +70,8 @@ class Game(object):
return 'T'
elif object.type == "waiter":
return 'W'
elif object.type == "orderTable":
return 'O'
def showGrid(self, grid):
charakterList = []

View File

@ -12,7 +12,7 @@ class Waiter(object):
self.image = pygame.image.load("./Images/w1.png").convert()
self.image.set_colorkey((255, 255, 255))
self.type = "waiter"
self.numberInGrid = game.idItem
def moveLeft(self, game):
if int(game.waiterNumberInGrid.x) != 0: