javascript game loop and game update design
Posted
by
zuo
on Game Development
See other posts from Game Development
or by zuo
Published on 2012-10-28T10:29:44Z
Indexed on
2012/10/28
11:23 UTC
Read the original article
Hit count: 501
JavaScript
|game-loop
There is a main game loop in my program, which calls game update every frame. However, to make better animation and better control, there is a need to implement a function like updateEveryNFrames(n, func)
.
I am considering implementing a counter for each update. The counter will be added by one each frame. The update function will be invoked according to the counter % n
.
For example, in a sequence of sprites animation, I can use the above function to control the speed of the animation.
Can some give some advice or other solutions?
© Game Development or respective owner