1 Replies - 2043 Views - Last Post: 27 June 2012 - 08:07 PM

#1 WolfCoder   User is offline

  • Isn't a volcano just an angry hill?
  • member icon


Reputation: 828
  • View blog
  • Posts: 7,696
  • Joined: 05-May 05

Frame Lock to FPS

Posted 17 January 2006 - 06:18 PM

Description: Add this to your constant frame rendering loops to lock it at a ceartin FPS.Make a frame render loop lock itself to a specific FPS.
public class frame_lock
{
 public static void main(String[] args)
 {
  // ...
  // Start of loop
  long fPS = 60; // Set to 60 frames a second
  long beginTime = System.currentTimeMillis(); // Get the current milliseconds
 
  // Do all the one-frame action here
  System.out.println("FRAME RENDERED");
  while(System.currentTimeMillis()-beginTime < 1000/fPS){} // Be idle until time is up
 
  // End of loop
  // ...  
 }
}


Is This A Good Question/Topic? 0
  • +

Replies To: Frame Lock to FPS

#2 wanz555   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 0
  • Joined: 27-June 12

Re: Frame Lock to FPS

Posted 27 June 2012 - 08:07 PM

how to compile in Dev c++ ?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1