lulzfish
Pandora Defense Squad
You can do what I did, connect a QTimer to some updateGameWorld() slot that updates the world, then calls update() on a widget. It works pretty well, you can find some way to measure how long the update-and-render step takes, then call a QBasicTimer to wait out the rest of the frame.loop:
{
updateGameLogic()
renderFrame()
waitUntilFrameEnd()
}
Basically, instead of running some stuff in a loop, you run that same stuff every time a timer calls an update function.
If a QTimer triggers while its slots are still processing, it just hides the trigger, so update is only ever called once at a time. Also, you can call it with interval 0 to just process all other events and then call your update as soon as possible.
I believe some of the Qt demos use a QTimer this way, like the wiggling text demo. I forget what it's called.
Last edited by a moderator: