From d300b2279c26bc3a07581cfb9957a5df5325d66f Mon Sep 17 00:00:00 2001 From: kleph Date: Mon, 3 Apr 2023 17:06:16 +0200 Subject: [PATCH] Lock the animation at 60 FPS --- py_hypercube.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/py_hypercube.py b/py_hypercube.py index 166ccbe..c9889a1 100755 --- a/py_hypercube.py +++ b/py_hypercube.py @@ -25,6 +25,7 @@ from OpenGL.GLUT import * ## MIN_INC = -100 MAX_INC = 100 +FPS = 60 ## # Variables globales @@ -71,8 +72,9 @@ varAnim = [randint(-100, 100), randint(-100, 100), randint(-100, 100)] -incAnim = [0.1, 0.1, 0.1, 0.1] - +# incAnim = [0.1, 0.1, 0.1, 0.1] +# incAnim = [0.05, 0.05, 0.05, 0.05] +incAnim = [1.0, 1.0, 1.0, 1.0] # fonction d'affichage principale def draw(): @@ -306,6 +308,7 @@ def draw_hypercube(a1, b1, c1, d1): pg.init() windowSize = (1152, 720) pg.display.set_mode(windowSize, DOUBLEBUF | OPENGL) +clock = pg.time.Clock() # setup PoV gluPerspective(60, (windowSize[0]/windowSize[1]), 0.1, 100.0) @@ -317,5 +320,7 @@ while True: if event.type == pg.KEYDOWN: keyboard(event.key) + # print('FPS: ' + str(clock.get_fps())) + clock.tick(FPS) draw() pg.display.flip()