As the jMonkeyEngine calculates the tpf?

I need to finish a 2D game that started in another library and to ensure the best quality of code wanted to use the tpf to keep the game speed of any PC how can I do this?

You can override simpleUpdate(float tpf) on SimpleApplication or update(float tpf) on AppStates and Controls

http://wiki.jmonkeyengine.org/doku.php/jme3:beginner:hello_main_event_loop

You do not understand … I’m trying to use the tpf in a game without jMonkeyEngine

We understood it the way you wrote it.

Anyway, in Java you can look up the current timestamp via:
http://docs.oracle.com/javase/7/docs/api/java/lang/System.html#currentTimeMillis()
http://docs.oracle.com/javase/7/docs/api/java/lang/System.html#nanoTime()
(depending on your needed “resolution”)

I had an idea that can solve my question: to calculate the Time Per Frame (TPF) at the beginning of the game loop will start a thread that will be increasing 1 to a variable and the end of the game loop will terminate the thread so I will get as time went pro game sue the loop! :grinning_face_with_smiling_eyes:

If only you could look at JME source code to see how it’s done…
Ho wait!

4 Likes

This is jme forum, so i guessed you were porting a game from another library to jme

But my question was how the tpf in jMonkeyEngine is done because I needed to use out of jME

Nehon you could not tell how it’s done in the tpf jME?

:smile: