HTML and CSS Reference
In-Depth Information
This chapter has covered the design and implementation of a deterministic main loop that was designed to run
in a browser. If you are a Dart programmer, you can use this library today by adding the game_loop package as a
dependency in your pubspec.yaml . If you are still using JavaScript, keep in mind the following when implementing
your own main loop:
frame callback registered with requestAnimationFrame .
Your main loop is driven by your
Your game update function needs a stable time delta: your frame callback must track how
much time has elapsed and call the update function when enough time has elapsed.
Watch out for leaking time and unbounded time accumulation.
Game timers should be built into the main loop so they are kept in sync with the game time.
User input from the browser should be buffered and available to be processed in the game
update function.
Render time may be ahead of game time. Use extrapolation or interpolation to get smooth
Abstract inputs into digital (down or up), analog (-1.0 to 1.0), and positional (touch and
mouse cursor).
By building on a solid main loop you can easily add support for detecting chorded inputs and sequence inputs.
Search WWH ::

Custom Search