Quack wrote:
In 10 fps how many times should I change the sprite to give the illusion of motion?
As Codehead suggests, this is not something that has a hard-and-fast "correct" answer... it depends on many factors -- the complexity of the animation, the number of frames, and so on. Then it still takes a subjective eye to find the motion that "feels" right.
Quack wrote:
and I think I will code the gameLoop function later after I get the other technical stuff right so can you pros tell how to make it work in every scenario? Or maybe I am taking a bad step here. Maybe I should think small now.
The game loop is pretty much the first thing I always work on -- in fact, it was the first feature I coded for my JavaScript game library (which I plan to release soon). The game loop is one of those parts of a real-time game that is pivotal, and should not wait, IMO.
To make it work in "every scenario" is pretty simple. The main idea is to separate the game loop from the game logic-state, and have the game loop control the logic-state. Also, you will want to measure the time between updates, and feed that to your logic-state so that it can "adjust" itself according to how much time has passed.
Let's say your logic-state has a function update(elapsedTime), which moves a sprite according to time. You would do something like this:
Code:
sprite.X += sprite.speed * elapsedTime;
For example, of course -- you would do things like collision handling in your own code, but that gives you an idea how it works.