Jump to content
  • Advertisement
Sign in to follow this  

[java] How to control animation speed in Java Applet?

This topic is 4070 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm pretty new to Java, and I've been making a couple simple Applet games to get my feet wet. I made a Pac Man game and a Super Mario game. I am controlling the game by running a big infinite loop inside the Run() method, then waiting a few milliseconds at the end with a thread.sleep() command. It gets the job done.. it will run through and update everything then redraw the screen and everything looks okay. The problem with doing it that way is that the game runs at a different speed on any given computer. Older computers will take longer to run through all the update and redraw commands, so the game runs in slow motion. I know there has to be a less-sloppy way to control the game's speed. I think I just need to separate the delay timer from the update commands so that the speed is controlled entirely by the computer's clock instead of the processing speed followed by the clock. Does that make sense?

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!