I don't know if this is the right place to ask and if its hard to understand what i mean or not but i hope its not that hard to understand.
Im trying to make a multiplayer game and i have a while loop that executes while the game is running but with faster computers and internet you can perform more updates than slower computers and also walk faster, attack faster etc. so i want to limit the updates per second to 60 or something like that so everyone will be the same. I know kinda how it works by calculating the difference between the last update and now. But i dont understand what every variable is doing and what it means. Can someone show me a little program that just has 60 updates per second and prints out the frames per second and the ticks per second which will be resetted every time and will be always around 60 but not more than that and just explain with comments very simply what it did?
Simply i want 2 variables which will be increased by 1 around 60 times and they will be printed out every second and then reset it again.
The output should be 95% of the time: "Frames: 60 - Updates: 60" so the game will be ipdated 60 times every second and the fps will be 60 too if the computer can do that else it may be less and laggy but maximum 60 for fast computers. But the Updates should be 60 for any computer.
Thanks in advance,
Re: Limit Updates
Search for and study "game loops" in Java. There are a couple very good tutorials or papers on the topic that walk you through the while( true ) loop to the more complex and describe the positives and negatives of each.
Re: Limit Updates
What you want is synchronization over the internet. If you are using a client-server architecture this can be done rather easily with the server giving the timings. If you have a peer-to-peer network it can be a little bit more complicated.