From 7e82a52039ab90acdc4ad22062d212b168e54e5e Mon Sep 17 00:00:00 2001 From: Arkadiusz Date: Tue, 26 Mar 2019 11:05:21 +0100 Subject: [PATCH] Lada i skromne kolizje --- .idea/workspace.xml | 117 ++++++++++++++++++++++++++++---------------- gridElement.py | 2 +- orderTable.py | 18 +++++++ run.py | 12 +++-- waiter.py | 2 +- 5 files changed, 101 insertions(+), 50 deletions(-) create mode 100644 orderTable.py diff --git a/.idea/workspace.xml b/.idea/workspace.xml index e4ebaf8..d31f217 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -1,8 +1,10 @@ - + + + @@ -17,17 +19,17 @@ - - + + - + - - + + @@ -38,17 +40,17 @@ - - + + - + - - + + @@ -59,7 +61,7 @@ - + @@ -74,6 +76,15 @@ + + + + + + + + + @@ -84,6 +95,11 @@ + @@ -91,10 +107,11 @@ @@ -206,7 +223,14 @@ \ No newline at end of file diff --git a/gridElement.py b/gridElement.py index b651897..a442b59 100644 --- a/gridElement.py +++ b/gridElement.py @@ -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 diff --git a/orderTable.py b/orderTable.py new file mode 100644 index 0000000..b59cedb --- /dev/null +++ b/orderTable.py @@ -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)) \ No newline at end of file diff --git a/run.py b/run.py index 9ae4ac9..5f8ed33 100644 --- a/run.py +++ b/run.py @@ -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 = [] diff --git a/waiter.py b/waiter.py index 725db87..597e65e 100644 --- a/waiter.py +++ b/waiter.py @@ -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: