Moss/sprite_stacking_engine/engine.py

37 lines
1 KiB
Python
Executable file

#!/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
class Engine:
def __init__(self, app):
self.app = app
self.surface = pygame.Surface(self.app.screen.get_size()) # surface to draw the sprites on
# 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)
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()