You can skip untill ******** if you don’t feel like reading a lots.
What you need is sleep based timer-hack. It makes you life tons and metric tons easier.
I don’t even think that you need to extend the thread in this situation. In your approach you start moving mountains if the sollution doesn’t come close to you, such as figuring a work around by extendin thread. This could be accomplished with much less work and brain power, but of course if you are the man for moving mountains, then man’s got to do what man’s go to do.
In your approach, the mountain is very hard to change. Thats why you need to work different way to do this.
The best thing for you would be setting FPS. All programs with animation have FPS and I can’t think of exceptations, except for animated gifs. (HAR HAR I MAKES TEH FUNNAY)
Now, once you have set fps, let’s say 60 or 75 would be great since about then the fps is high enough to be unnoticable. You must understand that refresh rate is the same as FPS, but done by your monitor. Computer on the other hand has capability to achieve much greater speeds than your monitor.
Although it might sound useless, it is not, since more objects you add to screen, the more it takes from the computer to do whatever required to keep them in animation.
Here is the simple part. Just set the thread running with the FPS, which is frames per second divided by 1000, since we are using milliseconds.
Now make that as the general speed of the loop. Now you have window/applet which screen content updates every fps/1000 millisecond. Amazing, isn’t it. Now you want to have something to animate. This even easier. Just make method which decides what to draw, and when.
Now comes the fun part: If you want things to animatie different speeds and want to see actually see the animation you have to set how many loops each picture is visible.
If you don’t set the delay for each picture to stay on screen, you will see bunch of pictures just flashing. This is not what you want. It makes you dizzy, you want animation, right?
Now you just set the delay, not hard and then decide how many loops each picture stays. You can do this by time too if you want the are afraid of high end systems going too fast, but if you have set cap FPS it won’t go too hard.
I have seen many different implementations, but time is harder, and generally better sollution.
Each sprite has animationtime attribute, which is the number of renderloops it stays on screen or switches to next frame. When its at next frame again it takes certain amount of loops untill it switches again to next one.
I’m sorry for my primitive grasp of english language, but if you have more questions, I will answer.