Mercurial > mamba
changeset 12:0196455fa432
Minimal event loop.
author | Simon Cross <hodgestar@gmail.com> |
---|---|
date | Sun, 11 Sep 2011 13:11:52 +0200 |
parents | 447311ee028c |
children | f5846a46e9c5 |
files | mamba/__main__.py mamba/engine.py |
diffstat | 2 files changed, 24 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/mamba/__main__.py Sun Sep 11 13:05:26 2011 +0200 +++ b/mamba/__main__.py Sun Sep 11 13:11:52 2011 +0200 @@ -6,6 +6,7 @@ from pygame.locals import SWSURFACE from mamba.constants import SCREEN +from mamba.engine import Engine # For future use DEBUG = False @@ -22,9 +23,5 @@ pygame.display.set_mode(SCREEN, SWSURFACE) pygame.display.set_caption('Mamba') - # Placeholder to do something for some time - import time - time.sleep(2) - - - + engine = Engine() + engine.run()
--- a/mamba/engine.py Sun Sep 11 13:05:26 2011 +0200 +++ b/mamba/engine.py Sun Sep 11 13:11:52 2011 +0200 @@ -0,0 +1,21 @@ +"""Game engine and top-level game loop.""" + +import pygame.event +import pygame.display +from pygame.locals import QUIT + + +class Engine(object): + def __init__(self): + pass + + def run(self): + """Game loop.""" + get_events = pygame.event.get + flip = pygame.display.flip + while True: + events = get_events() + for ev in events: + if ev.type is QUIT: + return + flip()