From: Stefano Rivera Date: Sun, 11 May 2014 15:59:51 +0000 (+0200) Subject: Limit frame rate X-Git-Tag: 0.1~418 X-Git-Url: https://git.ctpug.org.za/?a=commitdiff_plain;h=e1ba8711540872d716090a91e459f8e5309d1ccc;p=naja.git Limit frame rate --- diff --git a/naja/engine.py b/naja/engine.py index 94ddeab..1c6b70a 100644 --- a/naja/engine.py +++ b/naja/engine.py @@ -1,6 +1,7 @@ import pygame import pygame.locals as pgl +from naja.constants import FPS from naja.events import SceneChangeEvent, QuitGameEvent @@ -10,6 +11,7 @@ class Engine(object): self._scene = scene def run(self): + clock = pygame.time.Clock() while True: for ev in pygame.event.get(): if ev.type == pgl.QUIT or QuitGameEvent.matches(ev): @@ -21,6 +23,7 @@ class Engine(object): self._scene.handle_event(ev) self._scene.render(self._surface) pygame.display.flip() + clock.tick(FPS) def change_scene(self, scene): self._scene.exit()