1
0
forked from s444417/ProjektAI
ProjektAI/kelner/main.py
2020-03-22 21:52:12 +01:00

43 lines
1.3 KiB
Python

import pygame
from src.components.GridBoard import GridBoard
from src.components.Waiter import Waiter
#create screen consts
CellSize = 50 #pixel size of 1 square cell in the grid
GridCountX = 15 #number of columns in grid
GridCountY = 11 #number of rows in grid
ScreenWidth = CellSize * GridCountX #screen width in pixels
ScreenHeight = CellSize * GridCountY #screen height in pixels
#initialize background
gridBoard = GridBoard(ScreenWidth, ScreenHeight, CellSize)
#initialize waiter component
waiter = Waiter(1, 1, 0, GridCountX - 1, 0, GridCountY - 1, CellSize)
#loop
doRepaint = True
running = True
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_LEFT:
waiter.moveLeft()
if event.key == pygame.K_RIGHT:
waiter.moveRight()
if event.key == pygame.K_UP:
waiter.moveUp()
if event.key == pygame.K_DOWN:
waiter.moveDown()
doRepaint = True
if doRepaint:
gridBoard.reinitialize()
gridBoard.draw(waiter)
gridBoard.udpdate()
doRepaint = False