Added basic events
This commit is contained in:
parent
e8a8739c9d
commit
f535da1594
@ -1,3 +1,11 @@
|
|||||||
|
import pygame
|
||||||
|
|
||||||
|
|
||||||
class EventManager:
|
class EventManager:
|
||||||
def __init__(self):
|
def __init__(self, gameObject):
|
||||||
self.player
|
self.game = gameObject
|
||||||
|
|
||||||
|
def handleEvents(self):
|
||||||
|
for event in pygame.event.get():
|
||||||
|
if event.type == pygame.QUIT:
|
||||||
|
self.game.running = False
|
||||||
|
@ -2,6 +2,7 @@ import pygame
|
|||||||
import json
|
import json
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
from game.EventManager import EventManager
|
||||||
from game.Screen import Screen
|
from game.Screen import Screen
|
||||||
|
|
||||||
|
|
||||||
@ -35,10 +36,14 @@ class Game:
|
|||||||
self.screen = Screen(self, self.config["window"])
|
self.screen = Screen(self, self.config["window"])
|
||||||
print("OK")
|
print("OK")
|
||||||
|
|
||||||
|
self.eventManager = EventManager(self)
|
||||||
|
|
||||||
self.spritesList = pygame.sprite.Group()
|
self.spritesList = pygame.sprite.Group()
|
||||||
|
|
||||||
self.mainLoop()
|
self.mainLoop()
|
||||||
|
|
||||||
def mainLoop(self):
|
def mainLoop(self):
|
||||||
self.spritesList.draw(self.screen.pygameScreen)
|
while self.running:
|
||||||
pygame.display.flip()
|
self.eventManager.handleEvents()
|
||||||
|
self.spritesList.draw(self.screen.pygameScreen)
|
||||||
|
pygame.display.flip()
|
||||||
|
Loading…
Reference in New Issue
Block a user