High Fixed Rate Logic

Monkey Forums/Monkey Programming/High Fixed Rate Logic

erebel55(Posted 2014) [#1]
I am developing a game for android and ios that is getting close to release. For timing I found the following thread quite a while ago

http://www.monkeycoder.co.nz/Community/posts.php?topic=449

From here I copied the high fixed rate logic method that therevills uses in the following sample.



Is this method appropriate for my release? Or was it mainly for testing purposes?

I just want to make sure I am okay with leaving it as is.

Also, how was the framerate determined to be 200?
Field frameRate# = 200


Thank you


erebel55(Posted 2014) [#2]
Should I scrap this and use SetUpdateRate(0) ?


therevills(Posted 2014) [#3]
FRL and SetUpdateRate is different.

The FRL (Fixed-Rate-Logic) is running the OnUpdate at 200Hz (or tries to) whilst SetUpdateRate(0) will run OnUpdate and OnRender as fast as possible.

I used FRL so that the movement of objects wouldnt got thru walls, but I've changed now to use ray casting to detect collisions.


erebel55(Posted 2014) [#4]
Okay, thanks therevills. Any chance you have a dumbed down example of how the ray casting works? What method do you now use for timing, just delta timing?


ziggy(Posted 2014) [#5]
IMHO, delta timing with an minimum and maximum delta factor threshold is usually the easiest approach. Just in case the device is too slow, make the game slower before it drops too many frames and collisions start to fail, and also force the game to be slower if it's getting too quick on the device to prevent rounding errors caused by a too small delta factor.


ImmutableOctet(SKNG)(Posted 2014) [#6]
I'm not usually one to promote my own modules, but here's my delta-time module.

It's a delta-timing module I wrote a while ago, and it works reasonably well for my uses. Assuming of course that you haven't already looked into another solution.

For the STDCPP target, you'd need this module, but for other targets, it'll just use Mojo.


erebel55(Posted 2014) [#7]
Is FRL an appropriate alternative to delta timing?


therevills(Posted 2014) [#8]
Any chance you have a dumbed down example of how the ray casting works? What method do you now use for timing, just delta timing?


Ray casting:
Local pts:Vector2D[]
Local okayToMove:Bool = False
Local tempx = player.x + player.speedX
pts = BresenhamLine(New Vector2D(player.x, player.y), New Vector2D(tempx, player.y))
okayToMove = true
For Local v:Vector2D = EachIn pts
	if CollisionTile(v.x, v.y) <> 0 Then
		okayToMove = False
		player.x = v.x
		Exit
	End
Next

You fire a line from the start positionto the end position, checking each position.

Is FRL an appropriate alternative to delta timing?

No, you should use them together.