source: nagslang/engine.py@ 15:980339c28b42

Last change on this file since 15:980339c28b42 was 15:980339c28b42, checked in by Simon Cross <hodgestar@…>, 8 years ago

Add start of engine / event dispatcher.

File size: 695 bytes
Line 
1"""Top-level event dispatching and area transition."""
2
3from pygame import event
4from pygame import time
5import pygame.locals as pyl
6
7from nagslang import constants
8
9
10class Engine(object):
11 def __init__(self, screen):
12 self._screen = screen
13 self._clock = time.Clock()
14 self._fps = constants.FPS
15
16 def run(self):
17 running = True
18 while running:
19 for ev in event.get():
20 # TODO: dispatch these to an area
21 if ev.type == pyl.QUIT:
22 running = False
23 elif ev.type == pyl.KEYDOWN and ev.key == pyl.K_ESCAPE:
24 running = False
25 self._clock.tick(self._fps)
Note: See TracBrowser for help on using the repository browser.