Hi everyone,
It is recommendable to separate the rate of the logic (using a Timer) to the rate of the render? It penalizes the performance?
Thanks!
Different update rate for render and logicSoftware: Away3D 4.x |
||
louis87, Jr. Member
Posted: 17 October 2011 09:17 AM Total Posts: 46 Hi everyone, It is recommendable to separate the rate of the logic (using a Timer) to the rate of the render? It penalizes the performance? Thanks! |
||
Richard Olsson, Administrator
Posted: 17 October 2011 09:49 AM Total Posts: 1192 [ # 1 ] Before I say anything else, it’s important to understand that Flash Player does not support threading (yet) which means that you can’t really separate logic and rendering in a way that one doesn’t affect the performance of the other. However, what you can do, is to calculate AI logic and things like that only every third frame for example (or stretch the calculations evenly over three frames). As long as it’s possible for you to do so (i.e. NPC reactions don’t have to happen more often than that) it should leave more power to the render engine than doing those same calculations every frame. In the end, you’re gonna have to give it a try to see whether it delivers any noticeable performance increase for your use case. Let us know how it goes! |
||
|
||
TheSillyOne, Newbie
Posted: 01 November 2011 10:27 AM Total Posts: 28 [ # 3 ] Don’t wait for MT, you can learn a lot here! Check out schedulers and task queues. Also, please do not use a timer for this, you might regret it (jumpy frame rate etc.). Best regards. |
||
|
||
inSertCodE, Sr. Member
Posted: 03 November 2011 11:00 AM Total Posts: 105 [ # 5 ] I was thinking about same problem, how would I synchronize game running at same speed at different fps… I’m gonna go with the simplest solution. You convert the move distance to the current frame rate. You update the movement each frame. max move distance p/frame = max.movement p/s / max fps ... or because the max.movement p/s and max fps are constants you go straight max move distance p/frame = 1.6667 then you adjust the move distance per render to the current framerate move distance = (max.fps/fps) * max move distance p/s or move distance = (max.fps/fps) * 1.6667
-If your app runs at 30 fps for 5 seconds it will update 150 times -If your app runs at 23 fps for 5 seconds it will update 115 times The framerate can wary so you have to calculate the move distance each frame. This is how i see solution to time bounding. I’ll be glad if you could share some better ideas. |