1
0
Fork 0
ProjektAI/kelner/main.py

43 lines
1.3 KiB
Python
Raw Normal View History

2020-03-22 02:01:57 +01:00
import pygame
2020-03-22 21:52:12 +01:00
from src.components.GridBoard import GridBoard
from src.components.Waiter import Waiter
2020-03-22 02:01:57 +01:00
2020-03-22 21:52:12 +01:00
#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
2020-03-22 02:01:57 +01:00
2020-03-22 21:52:12 +01:00
#initialize background
gridBoard = GridBoard(ScreenWidth, ScreenHeight, CellSize)
2020-03-22 02:01:57 +01:00
2020-03-22 21:52:12 +01:00
#initialize waiter component
waiter = Waiter(1, 1, 0, GridCountX - 1, 0, GridCountY - 1, CellSize)
2020-03-22 02:01:57 +01:00
#loop
2020-03-22 21:52:12 +01:00
doRepaint = True
2020-03-22 02:01:57 +01:00
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:
2020-03-22 21:52:12 +01:00
waiter.moveLeft()
2020-03-22 02:01:57 +01:00
if event.key == pygame.K_RIGHT:
2020-03-22 21:52:12 +01:00
waiter.moveRight()
2020-03-22 02:01:57 +01:00
if event.key == pygame.K_UP:
2020-03-22 21:52:12 +01:00
waiter.moveUp()
2020-03-22 02:01:57 +01:00
if event.key == pygame.K_DOWN:
2020-03-22 21:52:12 +01:00
waiter.moveDown()
doRepaint = True
if doRepaint:
gridBoard.reinitialize()
gridBoard.draw(waiter)
gridBoard.udpdate()
doRepaint = False