94 lines
3.0 KiB
Python
94 lines
3.0 KiB
Python
|
import pygame, sys
|
||
|
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):
|
||
|
pygame.init()
|
||
|
self.x = 12
|
||
|
self.y = 12
|
||
|
self.screen = pygame.display.set_mode((self.x * 50, self.y * 50))
|
||
|
self.fpsClock = pygame.time.Clock()
|
||
|
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")
|
||
|
|
||
|
# The most important lists
|
||
|
self.grid = []
|
||
|
self.row = []
|
||
|
self.tableList = []
|
||
|
# Wygląd planszy i elementy
|
||
|
for b in range(self.y):
|
||
|
for i in range(self.x):
|
||
|
if ((i == 0) or (i == 11)) and ((b == 0) or (b == 7)):
|
||
|
self.row.append(Table(i * 50, b * 50, self))
|
||
|
elif (i == 7 and (b == 9 or b == 10 or b == 11)):
|
||
|
table = OrderTable(i * 50, b * 50, self)
|
||
|
self.row.append(table)
|
||
|
self.tableList.append(table)
|
||
|
elif i == 6 and b == 0:
|
||
|
self.row.append(Waiter(self, i * 50, b * 50))
|
||
|
self.waiterNumberInGrid.x = i
|
||
|
self.waiterNumberInGrid.y = b
|
||
|
else:
|
||
|
if ((i < 6) or (i > 8)) and b > 8:
|
||
|
pass
|
||
|
else:
|
||
|
self.row.append(GridElement(i * 50, b * 50, self))
|
||
|
if i == 11:
|
||
|
self.grid.append(list(self.row))
|
||
|
self.row.clear()
|
||
|
|
||
|
while True:
|
||
|
|
||
|
for event in pygame.event.get():
|
||
|
if event.type == pygame.QUIT:
|
||
|
sys.exit(0)
|
||
|
|
||
|
self.draw()
|
||
|
self.grid[int(self.waiterNumberInGrid.y)][int(self.waiterNumberInGrid.x)].move(self)
|
||
|
pygame.display.flip()
|
||
|
#print(self.waiterNumberInGrid)
|
||
|
self.fpsClock.tick(10)
|
||
|
|
||
|
def draw(self):
|
||
|
tempTable = []
|
||
|
for row in self.grid:
|
||
|
for gridElement in row:
|
||
|
if gridElement.type == "gridElement":
|
||
|
gridElement.draw()
|
||
|
else:
|
||
|
tempTable.append(gridElement)
|
||
|
for otherElement in tempTable:
|
||
|
otherElement.draw()
|
||
|
|
||
|
def convert(self, object):
|
||
|
if object.type == "gridElement":
|
||
|
return 'G'
|
||
|
elif object.type == "table":
|
||
|
return 'T'
|
||
|
elif object.type == "waiter":
|
||
|
return 'W'
|
||
|
elif object.type == "orderTable":
|
||
|
return 'O'
|
||
|
|
||
|
def showGrid(self, grid):
|
||
|
charakterList = []
|
||
|
row = []
|
||
|
for y in range(self.y):
|
||
|
row = list(map(self.convert, grid[y]))
|
||
|
charakterList.append(row)
|
||
|
print(row)
|
||
|
|
||
|
|
||
|
|
||
|
if __name__ == "__main__":
|
||
|
Game()
|