I need some working timing code.

BlitzMax Forums/BlitzMax Programming/I need some working timing code.

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

HrdNutz; Yeah basically originally I had an update loop running at 200Hz (this was pretty smooth). But then I also had this remainder left over each time and I hadn't really looked into tweening. So I decided to pass the remainder (as a fraction of 1) into the update function on the last iteration each frame - I call it delta. Normally the update function is passed 1. All my counters and so on are floating point and I multiply any changes to them by Delta. This seems to work totally fine, is very smooth and time is never lost.

Also I can turn off VSync and it works too. Quite often the time difference will be 0ms so the update loop won't get called but sometimes it's 1ms and it will get called ONCE but with a fractional delta. This means that my game timing works the same with VSync on or off. Also I can run a slow motion mode.

I even ran sswifts sprite physics demo with this code and it was fine.

I guess an alternative would be to keep the remainder and add it onto the next batch of update loop iterations instead so that only whole numbers are used.