Sign in to follow this  

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

Recommended Posts

chefgon_ign    100
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this