// Small script that prints the FPS to screen with regular intervals. class FPSTicker; import frames; // Set the FPS widget text native setText(char[][] args...); run() { // Sleep one frame. This makes sure that we won't start running until // the rendering begins. Not critically important, but it prevents the // first printed value from being 'nan'. fsleep(1); setText("hello!"); // counter and totalTime (in the 'frames' module) are updated // automatically by the system. ulong lastFrame = counter; float lastTime = totalTime; float delay = 1.5; while(true) { sleep(delay); // Calculate differences since last frame ulong fdiff = counter-lastFrame; float tdiff = totalTime-lastTime; setText("fps: ", fdiff / tdiff); lastFrame = counter; lastTime = totalTime; } }