Dodanie listy wszystkich elementow
This commit is contained in:
parent
a1ab3c9c4a
commit
1f63cd61be
@ -2,10 +2,8 @@
|
|||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="152ea650-8e02-4ed6-aa8c-04d44b275be4" name="Default Changelist" comment="">
|
<list default="true" id="152ea650-8e02-4ed6-aa8c-04d44b275be4" name="Default Changelist" comment="">
|
||||||
<change afterPath="$PROJECT_DIR$/.idea/vcs.xml" afterDir="false" />
|
|
||||||
<change afterPath="$PROJECT_DIR$/Images/order.py" afterDir="false" />
|
|
||||||
<change afterPath="$PROJECT_DIR$/gridElement.py" afterDir="false" />
|
|
||||||
<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$/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$/run.py" beforeDir="false" afterPath="$PROJECT_DIR$/run.py" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/table.py" beforeDir="false" afterPath="$PROJECT_DIR$/table.py" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/table.py" beforeDir="false" afterPath="$PROJECT_DIR$/table.py" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/waiter.py" beforeDir="false" afterPath="$PROJECT_DIR$/waiter.py" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/waiter.py" beforeDir="false" afterPath="$PROJECT_DIR$/waiter.py" afterDir="false" />
|
||||||
@ -21,17 +19,17 @@
|
|||||||
<file pinned="false" current-in-tab="false">
|
<file pinned="false" current-in-tab="false">
|
||||||
<entry file="file://$PROJECT_DIR$/table.py">
|
<entry file="file://$PROJECT_DIR$/table.py">
|
||||||
<provider selected="true" editor-type-id="text-editor">
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
<state relative-caret-position="306">
|
<state relative-caret-position="204">
|
||||||
<caret line="18" column="49" selection-start-line="18" selection-start-column="49" selection-end-line="18" selection-end-column="49" />
|
<caret line="12" column="33" selection-start-line="12" selection-start-column="33" selection-end-line="12" selection-end-column="33" />
|
||||||
</state>
|
</state>
|
||||||
</provider>
|
</provider>
|
||||||
</entry>
|
</entry>
|
||||||
</file>
|
</file>
|
||||||
<file pinned="false" current-in-tab="false">
|
<file pinned="false" current-in-tab="true">
|
||||||
<entry file="file://$PROJECT_DIR$/waiter.py">
|
<entry file="file://$PROJECT_DIR$/waiter.py">
|
||||||
<provider selected="true" editor-type-id="text-editor">
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
<state relative-caret-position="510">
|
<state relative-caret-position="350">
|
||||||
<caret line="30" column="61" selection-start-line="30" selection-start-column="61" selection-end-line="30" selection-end-column="61" />
|
<caret line="26" column="12" selection-start-line="26" selection-start-column="12" selection-end-line="26" selection-end-column="12" />
|
||||||
<folding>
|
<folding>
|
||||||
<element signature="e#0#13#0" expanded="true" />
|
<element signature="e#0#13#0" expanded="true" />
|
||||||
</folding>
|
</folding>
|
||||||
@ -42,8 +40,8 @@
|
|||||||
<file pinned="false" current-in-tab="false">
|
<file pinned="false" current-in-tab="false">
|
||||||
<entry file="file://$PROJECT_DIR$/gridElement.py">
|
<entry file="file://$PROJECT_DIR$/gridElement.py">
|
||||||
<provider selected="true" editor-type-id="text-editor">
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
<state relative-caret-position="187">
|
<state relative-caret-position="102">
|
||||||
<caret line="11" column="58" selection-start-line="11" selection-start-column="58" selection-end-line="11" selection-end-column="58" />
|
<caret line="6" column="33" selection-start-line="6" selection-start-column="33" selection-end-line="6" selection-end-column="33" />
|
||||||
</state>
|
</state>
|
||||||
</provider>
|
</provider>
|
||||||
</entry>
|
</entry>
|
||||||
@ -51,8 +49,8 @@
|
|||||||
<file pinned="false" current-in-tab="false">
|
<file pinned="false" current-in-tab="false">
|
||||||
<entry file="file://$PROJECT_DIR$/run.py">
|
<entry file="file://$PROJECT_DIR$/run.py">
|
||||||
<provider selected="true" editor-type-id="text-editor">
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
<state relative-caret-position="204">
|
<state relative-caret-position="537">
|
||||||
<caret line="12" column="24" selection-start-line="12" selection-start-column="24" selection-end-line="12" selection-end-column="24" />
|
<caret line="42" column="42" lean-forward="true" selection-start-line="42" selection-start-column="42" selection-end-line="42" selection-end-column="42" />
|
||||||
<folding>
|
<folding>
|
||||||
<element signature="e#0#18#0" expanded="true" />
|
<element signature="e#0#18#0" expanded="true" />
|
||||||
</folding>
|
</folding>
|
||||||
@ -60,11 +58,11 @@
|
|||||||
</provider>
|
</provider>
|
||||||
</entry>
|
</entry>
|
||||||
</file>
|
</file>
|
||||||
<file pinned="false" current-in-tab="true">
|
<file pinned="false" current-in-tab="false">
|
||||||
<entry file="file://$PROJECT_DIR$/Images/order.py">
|
<entry file="file://$PROJECT_DIR$/order.py">
|
||||||
<provider selected="true" editor-type-id="text-editor">
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
<state relative-caret-position="85">
|
<state relative-caret-position="85">
|
||||||
<caret line="5" column="4" selection-start-line="5" selection-start-column="4" selection-end-line="5" selection-end-column="4" />
|
<caret line="5" selection-start-line="5" selection-end-line="5" />
|
||||||
</state>
|
</state>
|
||||||
</provider>
|
</provider>
|
||||||
</entry>
|
</entry>
|
||||||
@ -72,7 +70,7 @@
|
|||||||
<file pinned="false" current-in-tab="false">
|
<file pinned="false" current-in-tab="false">
|
||||||
<entry file="file://$USER_HOME$/Desktop/pygame-elsa/elsa_gra.py">
|
<entry file="file://$USER_HOME$/Desktop/pygame-elsa/elsa_gra.py">
|
||||||
<provider selected="true" editor-type-id="text-editor">
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
<state relative-caret-position="1020">
|
<state relative-caret-position="537">
|
||||||
<caret line="66" column="32" selection-start-line="66" selection-start-column="17" selection-end-line="66" selection-end-column="32" />
|
<caret line="66" column="32" selection-start-line="66" selection-start-column="17" selection-end-line="66" selection-end-column="32" />
|
||||||
</state>
|
</state>
|
||||||
</provider>
|
</provider>
|
||||||
@ -103,11 +101,11 @@
|
|||||||
<option name="CHANGED_PATHS">
|
<option name="CHANGED_PATHS">
|
||||||
<list>
|
<list>
|
||||||
<option value="$PROJECT_DIR$/1" />
|
<option value="$PROJECT_DIR$/1" />
|
||||||
<option value="$PROJECT_DIR$/table.py" />
|
|
||||||
<option value="$PROJECT_DIR$/waiter.py" />
|
|
||||||
<option value="$PROJECT_DIR$/gridElement.py" />
|
|
||||||
<option value="$PROJECT_DIR$/run.py" />
|
|
||||||
<option value="$PROJECT_DIR$/Images/order.py" />
|
<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$/waiter.py" />
|
||||||
</list>
|
</list>
|
||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
@ -125,7 +123,6 @@
|
|||||||
<foldersAlwaysOnTop value="true" />
|
<foldersAlwaysOnTop value="true" />
|
||||||
</navigator>
|
</navigator>
|
||||||
<panes>
|
<panes>
|
||||||
<pane id="Scope" />
|
|
||||||
<pane id="ProjectPane">
|
<pane id="ProjectPane">
|
||||||
<subPane>
|
<subPane>
|
||||||
<expand>
|
<expand>
|
||||||
@ -142,6 +139,7 @@
|
|||||||
<select />
|
<select />
|
||||||
</subPane>
|
</subPane>
|
||||||
</pane>
|
</pane>
|
||||||
|
<pane id="Scope" />
|
||||||
</panes>
|
</panes>
|
||||||
</component>
|
</component>
|
||||||
<component name="PropertiesComponent">
|
<component name="PropertiesComponent">
|
||||||
@ -150,6 +148,7 @@
|
|||||||
</component>
|
</component>
|
||||||
<component name="RecentsManager">
|
<component name="RecentsManager">
|
||||||
<key name="MoveFile.RECENT_KEYS">
|
<key name="MoveFile.RECENT_KEYS">
|
||||||
|
<recent name="C:\Users\user\PycharmProjects\Test\Sztuczna_Inteligencja" />
|
||||||
<recent name="C:\Users\user\PycharmProjects\Test\Images" />
|
<recent name="C:\Users\user\PycharmProjects\Test\Images" />
|
||||||
</key>
|
</key>
|
||||||
</component>
|
</component>
|
||||||
@ -204,6 +203,14 @@
|
|||||||
<option name="presentableId" value="Default" />
|
<option name="presentableId" value="Default" />
|
||||||
<updated>1552504215314</updated>
|
<updated>1552504215314</updated>
|
||||||
</task>
|
</task>
|
||||||
|
<task id="LOCAL-00001" summary="Dodanie gridElement">
|
||||||
|
<created>1553110976143</created>
|
||||||
|
<option name="number" value="00001" />
|
||||||
|
<option name="presentableId" value="LOCAL-00001" />
|
||||||
|
<option name="project" value="LOCAL" />
|
||||||
|
<updated>1553110976143</updated>
|
||||||
|
</task>
|
||||||
|
<option name="localTasksCounter" value="2" />
|
||||||
<servers />
|
<servers />
|
||||||
</component>
|
</component>
|
||||||
<component name="TodoView">
|
<component name="TodoView">
|
||||||
@ -238,6 +245,10 @@
|
|||||||
<window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
|
<window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
|
||||||
</layout>
|
</layout>
|
||||||
</component>
|
</component>
|
||||||
|
<component name="VcsManagerConfiguration">
|
||||||
|
<MESSAGE value="Dodanie gridElement" />
|
||||||
|
<option name="LAST_COMMIT_MESSAGE" value="Dodanie gridElement" />
|
||||||
|
</component>
|
||||||
<component name="editorHistoryManager">
|
<component name="editorHistoryManager">
|
||||||
<entry file="file://$PROJECT_DIR$/1">
|
<entry file="file://$PROJECT_DIR$/1">
|
||||||
<provider selected="true" editor-type-id="text-editor">
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
@ -270,13 +281,6 @@
|
|||||||
</state>
|
</state>
|
||||||
</provider>
|
</provider>
|
||||||
</entry>
|
</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://$PROJECT_DIR$/Images/tlo.jpg">
|
<entry file="file://$PROJECT_DIR$/Images/tlo.jpg">
|
||||||
<provider selected="true" editor-type-id="images" />
|
<provider selected="true" editor-type-id="images" />
|
||||||
</entry>
|
</entry>
|
||||||
@ -287,44 +291,51 @@
|
|||||||
</state>
|
</state>
|
||||||
</provider>
|
</provider>
|
||||||
</entry>
|
</entry>
|
||||||
|
<entry file="file://$PROJECT_DIR$/order.py">
|
||||||
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
|
<state relative-caret-position="85">
|
||||||
|
<caret line="5" selection-start-line="5" selection-end-line="5" />
|
||||||
|
</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="537">
|
||||||
|
<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$/table.py">
|
<entry file="file://$PROJECT_DIR$/table.py">
|
||||||
<provider selected="true" editor-type-id="text-editor">
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
<state relative-caret-position="306">
|
<state relative-caret-position="204">
|
||||||
<caret line="18" column="49" selection-start-line="18" selection-start-column="49" selection-end-line="18" selection-end-column="49" />
|
<caret line="12" column="33" selection-start-line="12" selection-start-column="33" selection-end-line="12" selection-end-column="33" />
|
||||||
</state>
|
|
||||||
</provider>
|
|
||||||
</entry>
|
|
||||||
<entry file="file://$PROJECT_DIR$/gridElement.py">
|
|
||||||
<provider selected="true" editor-type-id="text-editor">
|
|
||||||
<state relative-caret-position="187">
|
|
||||||
<caret line="11" column="58" selection-start-line="11" selection-start-column="58" selection-end-line="11" selection-end-column="58" />
|
|
||||||
</state>
|
|
||||||
</provider>
|
|
||||||
</entry>
|
|
||||||
<entry file="file://$PROJECT_DIR$/waiter.py">
|
|
||||||
<provider selected="true" editor-type-id="text-editor">
|
|
||||||
<state relative-caret-position="510">
|
|
||||||
<caret line="30" column="61" selection-start-line="30" selection-start-column="61" selection-end-line="30" selection-end-column="61" />
|
|
||||||
<folding>
|
|
||||||
<element signature="e#0#13#0" expanded="true" />
|
|
||||||
</folding>
|
|
||||||
</state>
|
</state>
|
||||||
</provider>
|
</provider>
|
||||||
</entry>
|
</entry>
|
||||||
<entry file="file://$PROJECT_DIR$/run.py">
|
<entry file="file://$PROJECT_DIR$/run.py">
|
||||||
<provider selected="true" editor-type-id="text-editor">
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
<state relative-caret-position="204">
|
<state relative-caret-position="537">
|
||||||
<caret line="12" column="24" selection-start-line="12" selection-start-column="24" selection-end-line="12" selection-end-column="24" />
|
<caret line="42" column="42" lean-forward="true" selection-start-line="42" selection-start-column="42" selection-end-line="42" selection-end-column="42" />
|
||||||
<folding>
|
<folding>
|
||||||
<element signature="e#0#18#0" expanded="true" />
|
<element signature="e#0#18#0" expanded="true" />
|
||||||
</folding>
|
</folding>
|
||||||
</state>
|
</state>
|
||||||
</provider>
|
</provider>
|
||||||
</entry>
|
</entry>
|
||||||
<entry file="file://$PROJECT_DIR$/Images/order.py">
|
<entry file="file://$PROJECT_DIR$/gridElement.py">
|
||||||
<provider selected="true" editor-type-id="text-editor">
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
<state relative-caret-position="85">
|
<state relative-caret-position="102">
|
||||||
<caret line="5" column="4" selection-start-line="5" selection-start-column="4" selection-end-line="5" selection-end-column="4" />
|
<caret line="6" column="33" selection-start-line="6" selection-start-column="33" selection-end-line="6" selection-end-column="33" />
|
||||||
|
</state>
|
||||||
|
</provider>
|
||||||
|
</entry>
|
||||||
|
<entry file="file://$PROJECT_DIR$/waiter.py">
|
||||||
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
|
<state relative-caret-position="350">
|
||||||
|
<caret line="26" column="12" selection-start-line="26" selection-start-column="12" selection-end-line="26" selection-end-column="12" />
|
||||||
|
<folding>
|
||||||
|
<element signature="e#0#13#0" expanded="true" />
|
||||||
|
</folding>
|
||||||
</state>
|
</state>
|
||||||
</provider>
|
</provider>
|
||||||
</entry>
|
</entry>
|
||||||
|
@ -1,11 +1,14 @@
|
|||||||
import pygame
|
import pygame
|
||||||
|
|
||||||
class GridEleemnt(object):
|
class GridElement(object):
|
||||||
def __init__(self,x,y,game):
|
def __init__(self,x,y,game):
|
||||||
self.game = game
|
self.game = game
|
||||||
|
game.idItem += 1
|
||||||
|
self.number = game.idItem
|
||||||
self.x = x
|
self.x = x
|
||||||
self.y = y
|
self.y = y
|
||||||
self.image = pygame.image.load("./Images/plytka.png")
|
self.image = pygame.image.load("./Images/plytka.png")
|
||||||
|
self.type = "gridElement"
|
||||||
|
|
||||||
def draw(self):
|
def draw(self):
|
||||||
self.rect = pygame.Rect(self.x, self.y, 50, 50)
|
self.rect = pygame.Rect(self.x, self.y, 50, 50)
|
||||||
|
52
run.py
52
run.py
@ -1,7 +1,8 @@
|
|||||||
import pygame, sys
|
import pygame, sys
|
||||||
from waiter import Waiter
|
from waiter import Waiter
|
||||||
from table import Table
|
from table import Table
|
||||||
from gridElement import GridEleemnt
|
from gridElement import GridElement
|
||||||
|
|
||||||
|
|
||||||
class Game(object):
|
class Game(object):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@ -11,19 +12,24 @@ class Game(object):
|
|||||||
self.fpsClock = pygame.time.Clock()
|
self.fpsClock = pygame.time.Clock()
|
||||||
self.idTable = 0
|
self.idTable = 0
|
||||||
self.idOrder = 0
|
self.idOrder = 0
|
||||||
|
self.idItem = -1
|
||||||
|
self.waiterNumberInGrid = 0
|
||||||
pygame.display.set_caption('Automatic Waiter')
|
pygame.display.set_caption('Automatic Waiter')
|
||||||
self.background = pygame.image.load("./Images/tlo.jpg")
|
self.background = pygame.image.load("./Images/tlo.jpg")
|
||||||
|
|
||||||
self.waiter = Waiter(self)
|
# The most important list
|
||||||
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)]
|
|
||||||
self.grid = []
|
self.grid = []
|
||||||
for i in range(20):
|
|
||||||
for b in range(18):
|
|
||||||
self.grid.append(GridEleemnt(i*50, b*50, self))
|
|
||||||
|
|
||||||
|
|
||||||
for t in self.tables:
|
for b in range(18):
|
||||||
print(t.id)
|
for i in range(20):
|
||||||
|
if ((i == 0) or (i == 8) or (i == 16)) and ((b == 2) or (b == 8)):
|
||||||
|
self.grid.append(Table(i * 50, b * 50, self))
|
||||||
|
elif i == 18 and b == 14:
|
||||||
|
self.grid.append(Waiter(self, i * 50, b * 50))
|
||||||
|
self.waiterNumberInGrid = (b * 20) + i
|
||||||
|
else:
|
||||||
|
self.grid.append(GridElement(i * 50, b * 50, self))
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
|
|
||||||
@ -31,31 +37,23 @@ class Game(object):
|
|||||||
if event.type == pygame.QUIT:
|
if event.type == pygame.QUIT:
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
#self.screen.fill((0, 0, 0))
|
|
||||||
#self.screen.blit(self.background, (0, 0))
|
|
||||||
self.draw()
|
self.draw()
|
||||||
self.waiter.move()
|
self.grid[self.waiterNumberInGrid].move(self)
|
||||||
pygame.display.flip()
|
pygame.display.flip()
|
||||||
|
print(self.waiterNumberInGrid)
|
||||||
self.fpsClock.tick(10)
|
self.fpsClock.tick(10)
|
||||||
|
|
||||||
|
|
||||||
def draw(self):
|
def draw(self):
|
||||||
|
|
||||||
|
tempTable = []
|
||||||
for gridElement in self.grid:
|
for gridElement in self.grid:
|
||||||
gridElement.draw()
|
if gridElement.type == "gridElement":
|
||||||
self.waiter.draw()
|
gridElement.draw()
|
||||||
for table in self.tables:
|
else:
|
||||||
table.draw()
|
tempTable.append(gridElement)
|
||||||
|
for otherElement in tempTable:
|
||||||
|
otherElement.draw()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
Game()
|
Game()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
3
table.py
3
table.py
@ -9,9 +9,12 @@ class Table(object):
|
|||||||
self.width = width
|
self.width = width
|
||||||
self.game = game
|
self.game = game
|
||||||
game.idTable += 1
|
game.idTable += 1
|
||||||
|
game.idItem += 1
|
||||||
|
self.number = game.idItem
|
||||||
self.isBusy = False
|
self.isBusy = False
|
||||||
self.id = game.idTable
|
self.id = game.idTable
|
||||||
self.image = pygame.image.load("./Images/tableSmall.png")
|
self.image = pygame.image.load("./Images/tableSmall.png")
|
||||||
|
self.type = "table"
|
||||||
|
|
||||||
def draw(self):
|
def draw(self):
|
||||||
self.table = pygame.Rect(self.x, self.y, 50, 50)
|
self.table = pygame.Rect(self.x, self.y, 50, 50)
|
||||||
|
28
waiter.py
28
waiter.py
@ -3,29 +3,33 @@ from pygame.math import Vector2
|
|||||||
|
|
||||||
class Waiter(object):
|
class Waiter(object):
|
||||||
|
|
||||||
def __init__(self, game):
|
def __init__(self, game, x, y):
|
||||||
self.game = game
|
self.game = game
|
||||||
|
game.idItem += 1
|
||||||
self.size= self.game.screen.get_size()
|
self.size= self.game.screen.get_size()
|
||||||
self.position = Vector2(self.size[0]-100,self.size[1]-200)
|
self.x = x
|
||||||
|
self.y = y
|
||||||
self.image = pygame.image.load("./Images/w1.png").convert()
|
self.image = pygame.image.load("./Images/w1.png").convert()
|
||||||
self.image.set_colorkey((255, 255, 255))
|
self.image.set_colorkey((255, 255, 255))
|
||||||
|
self.type = "waiter"
|
||||||
|
self.numberInGrid = game.idItem
|
||||||
|
|
||||||
def changePosition(self, vector):
|
def changePosition(self, vector):
|
||||||
self.position += vector
|
self.position += vector
|
||||||
|
|
||||||
|
|
||||||
def move(self):
|
def move(self, game):
|
||||||
keys = pygame.key.get_pressed()
|
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]:
|
if keys[pygame.K_LEFT]:
|
||||||
self.changePosition(Vector2(-50,0))
|
tmp = game.grid[game.waiterNumberInGrid-1]
|
||||||
|
tmp.x = tmp.x+50
|
||||||
|
game.grid[game.waiterNumberInGrid-1] = game.grid[game.waiterNumberInGrid]
|
||||||
|
game.grid[game.waiterNumberInGrid-1].x -= 50
|
||||||
|
game.grid[game.waiterNumberInGrid] = tmp
|
||||||
|
game.waiterNumberInGrid -= 1
|
||||||
|
|
||||||
|
|
||||||
def draw(self):
|
def draw(self):
|
||||||
self.rect1 = pygame.Rect(self.position.x, self.position.y, 50, 100)
|
self.rect1 = pygame.Rect(self.x, self.y, 50, 50)
|
||||||
pygame.draw.rect(self.game.screen, (0, 150, 255), self.rect1)
|
pygame.draw.rect(self.game.screen, (0, 150, 255), self.rect1)
|
||||||
self.game.screen.blit(self.image, (self.position.x-50, self.position.y))
|
self.game.screen.blit(self.image, (self.x-50, self.y))
|
||||||
|
Loading…
Reference in New Issue
Block a user