Ok, so first of all I would like to say that I'm still very 'Noob-ish' when it comes to programming in Java.
I'm creating a simple game, however I thought it would be a nice challenge to display the frames per second in my game.
But all the articles about it are really complex (for me) , and nobody seems to have a game loop the way I do.
This is what my game loop looks like:
My Main class extends the JPanel
public class Main extends JPanel {
Also in my main class the game loop, it uses the default repaint() method. In wich I draw all the images etc.
public void run() { while (true) { long time = System.currentTimeMillis(); repaint(); time = (1000 / Globals.maxFPS) - (System.currentTimeMillis() - time); if (time > 0) { try { Thread.sleep(time); } catch (Exception e) } } } }
My first thought was to calculate the FPS using the time variable, however no mather how slow the game goes time is always 16. So I realy don't understand how I should calculate the FPS in this game loop.
If you need any more information I'll be happy to give it
Thanks in Advance,
Dirk