SFML community forums
Bindings - other languages => Python => Topic started by: Kubik on September 05, 2012, 09:04:02 pm
-
I try to get fps by this way:
self.FPS = 1.0 / self.window.GetFrameTime(), but get ZeroDivisionError: float division, so how get fps
-
Make sure that self.window.GetFrameTime() is not zero.
-
i know that and i know reason of problem i try to conversion types, not helped
-
i know that and i know reason of problem i try to conversion types, not helped
Hu? ???
You get a devision by Zero most probably because GetFrameTime() is 0, I don't see what this has to do with type conversion...
-
yes, i don't write in example type conversion, but why i get zero? maybe i must do anything else? How get fps?
-
It's not your 'fault' that GetFrameTime() returns 0, it's the inaccuracy of floats...
Have you taken a look at the Python binding for SFML 2, because the API has changed and a new class was introduced sf::Time which works around this problem.
To 'fix' your problem with the binding you're using now, you can either check if GetFrameTime() is zero and if so, define the FPS as infinite or very very high, or you could always blindly add some small number to it (e.g. 0.00001)
-
:) no i would use fraps, thank you