Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Limit Updates

  1. #1
    Junior Member
    Join Date
    May 2014
    Thanked 0 Times in 0 Posts

    Question Limit Updates


    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,

  2. #2
    Super Moderator
    Join Date
    Jun 2013
    So. Maryland, USA
    My Mood
    Thanked 698 Times in 680 Posts

    Default 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.

  3. #3
    Senior Member
    Join Date
    Jul 2013
    Thanked 121 Times in 105 Posts

    Default 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.

Similar Threads

  1. Replies: 1
    Last Post: July 12th, 2014, 04:19 AM
  2. Jtable only updates at the end of a buton event.
    By covi454 in forum AWT / Java Swing
    Replies: 1
    Last Post: April 2nd, 2013, 11:05 AM
  3. [SOLVED] How to get Progress updates from multiple threads...
    By Becca in forum Threads
    Replies: 4
    Last Post: February 7th, 2012, 01:34 PM
  4. Variable updates after loop
    By tecno40 in forum Loops & Control Statements
    Replies: 1
    Last Post: November 9th, 2011, 05:34 AM
  5. [SOLVED] Trojans with last few updates of NetBeans
    By Melawe in forum Java IDEs
    Replies: 11
    Last Post: May 22nd, 2010, 08:33 AM

Tags for this Thread