Moss/sprite_stacking_engine/engine.py

38 lines
1 KiB
Python
Raw Normal View History

2024-07-18 10:53:51 +02:00
#!/usr/bin/python3
import sys
from sprite_stacking_engine.settings import *
from sprite_stacking_engine.cache import Cache
from sprite_stacking_engine.player import Player
from sprite_stacking_engine.scene import Scene
2024-07-18 10:53:51 +02:00
class Engine:
def __init__(self, app):
self.app = app
self.surface = pygame.Surface(self.app.screen.get_size()) # surface to draw the sprites on
2024-07-18 10:53:51 +02:00
# groups
self.main_group = pygame.sprite.LayeredUpdates()
# game objects
self.cache = Cache()
self.player = Player(self)
self.scene = Scene(self)
def update(self):
self.main_group.update()
def draw(self):
self.surface.fill(BG_COLOR)
self.main_group.draw(self.surface)
2024-07-18 10:53:51 +02:00
def check_events(self):
for event in pygame.event.get():
if event.type == pygame.QUIT or (event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE):
pygame.quit()
sys.exit()
def tick(self):
self.check_events()
self.update()
self.draw()