Mercurial > skaapsteker
diff skaapsteker/engine.py @ 11:249814efa91b
Create game engine. Enable quitting.
author | Simon Cross <hodgestar@gmail.com> |
---|---|
date | Sun, 03 Apr 2011 15:59:16 +0200 |
parents | |
children | fb1bd081cc86 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/skaapsteker/engine.py Sun Apr 03 15:59:16 2011 +0200 @@ -0,0 +1,21 @@ +"""Top-level engine for switching scenes.""" + +import pygame.display +import pygame.time +import pygame.event +from pygame.locals import QUIT + +class Engine(object): + + def __init__(self): + self._framerate = 60 + + def run(self): + """Run the game loop dispatching events as necessary.""" + clock = pygame.time.Clock() + while True: + events = pygame.event.get() + for ev in events: + if ev.type is QUIT: + return + clock.tick(self._framerate)