Best FPS method #595
Replies: 3 comments
-
Posted at 2016-06-09 by @allObjects Since
This works well if you do not have asynchronous stuff in you |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-06-09 by Owen That's an interesting idea. I've also been looking at a similar method where you removed any frame based animation and only use time based animation. So instead of for example "5 spaces per frame" you use "150 spaces per second" and the code decided how to move the item each frame output. Here is a detailed article on JavaScript game loops and timing: http://www.isaacsukin.com/news/2015/01/detailed-explanation-javascript-game-loops-and-timing |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-06-09 by @allObjects It is usually better to keep independent 'things' independent - in their own 'threads' (timeout or event driven) - and only manage the coop of dependent 'things'. Nice part about Javascript's single-threaded-ness and the available immense computing power makes 'logical multithreaded' things quite simple. Last but not least - even if you have a multi-core - most software is executed single-threaded anyway... nothing conceptional really new for over 50+ years... just more efficient and more transparent for the application developer, more 'plumbing' moves into the platform/containers. So fare I was not much in gaming but more in efficiently rendering large pages where many resources have to be retrieved from different places and the user experience should still be smooth... Because MC/IoT/Espruino has even more challenges - almost all communication with any peripheral is callback oriented - I built for myself something like a global controller that allows sequencing of tasks of callback driven components. The challenging part is that 'you have to wait, but you do not know how long'. Of course you can define 'frames' (to show the similarity of the challenges) of 5 minutes or longer for completion of, for example, creating a connection, and after that one to get data across that connection, etc. But what do you do if after waiting overly long things still didn't complete, or worse, failed right away, but only now action can be taken... Espruino's All is still a work in progress... and to have a a single universal component that provides platform with all functions is a challenge. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2016-06-08 by Owen
Hello,
What is the best method for frame based animations/games to get accurate FPS?
The two methods I've tried are:
This works well but if the tick() function ever takes longer than the interval time they can begin to stack up on one another.
The second method I've tried is setTimeout from within the tick() function. The only problem I have here is the FPS drop a lot as each frame is tick() excuse time + frame timeout.
Are there any other methods I can look at, like using the system time to decide when to next call tick()?
Beta Was this translation helpful? Give feedback.
All reactions