That’s the best title I could come up with, I’ve got two game modes:
- get as many points as you can in X amount of time
- how fast can you get to X points
Both of these obviously need good time keeping, for the second I’m calling a function every tenth of a second to update the on screen timer.
GameTimer = timer.performWithDelay(100, UpdateTimer, 0)
The timer seemed to be running slowly so I added some debug code to see how many miliiseconds there was really between each time the function was called.
time\_debug = system.getTimer()
GameTimer = timer.performWithDelay(100, UpdateTimer, 0)
function UpdateTimer()
local time\_out = tostring(system.getTimer() - time\_debug)
print('game time ' .. time\_out)
time\_debug = system.getTimer()
end
The actual delay comes back as 112 or 132 depending if I’m running 60 or 30 fps. I appreciate the timers aren’t guaranteed but is there a good solution to this?
- I could use the actual delay to update the screen time (and game time) rather than relying on the time to fire with the exact delay.
- Can I shift it off onto a separate thread?
- Is there a better way of doing this rather than using the timer functions? [import]uid: 68937 topic_id: 11818 reply_id: 311818[/import]