There are a few ways to cap framerate, but if all you want to do is:
Specifically the rendering should only render when the logic has been updated instead of rendering redundant frames (i.e., when no logic update has occurred).
Then you could just set a simple boolean flag. Set it to true in update_game()
, and check it in onDraw()
. If it's false, just return without drawing/clearing the screen. If true, do your drawing and set it to false;