Added basic events

This commit is contained in:
Marcin Kostrzewski 2020-04-02 17:30:25 +02:00
parent e8a8739c9d
commit f535da1594
2 changed files with 17 additions and 4 deletions

View File

@ -1,3 +1,11 @@
import pygame
class EventManager:
def __init__(self):
self.player
def __init__(self, gameObject):
self.game = gameObject
def handleEvents(self):
for event in pygame.event.get():
if event.type == pygame.QUIT:
self.game.running = False

View File

@ -2,6 +2,7 @@ import pygame
import json
from pathlib import Path
from game.EventManager import EventManager
from game.Screen import Screen
@ -35,10 +36,14 @@ class Game:
self.screen = Screen(self, self.config["window"])
print("OK")
self.eventManager = EventManager(self)
self.spritesList = pygame.sprite.Group()
self.mainLoop()
def mainLoop(self):
while self.running:
self.eventManager.handleEvents()
self.spritesList.draw(self.screen.pygameScreen)
pygame.display.flip()