From e1ba8711540872d716090a91e459f8e5309d1ccc Mon Sep 17 00:00:00 2001 From: Stefano Rivera Date: Sun, 11 May 2014 17:59:51 +0200 Subject: [PATCH] Limit frame rate --- naja/engine.py | 3 +++ 1 file changed, 3 insertions(+) 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() -- 2.34.1