SFML community forums
Bindings - other languages => Python => Topic started by: grim on August 28, 2014, 01:46:38 am
-
I'm converting my c++ sfml project to python sfml and I'm have a bit of confusion about event handling in pysfml. I was going to just use the window.poll_event() but I saw in the documentation an example that used a for loop that started as for event in window.events. Is there any real difference between the two event listeners?
For my second question, do I still have to worry about sleep/wait timers? I only ask because the last time I focused on a game project was in high school, when I was told to to put a sleep method for about 5 milliseconds that i would put at the end of the handling/update/draw cycle. Do I still need to do that, because I've looked through a lot of reference material for different libraries and I see no mention for that.
-
You don't need to use sleep. Enable vertical synchronization or set a frame rate limit (both are functions of sf::Window) if you don't want your program to use every available resources.
-
Alright but what about the two event listeners could I just use the window.poll_event() like I originally intended or would it be better to use the four loop as shown in the documentation example?
-
I've never used SFML with python so I can't answer you, sorry. :p
-
I guess I'll figure it out when I get to the point that I have to worry about a bunch of event handling stuff.
-
Usually, SFML bindings add stuff more specific (adapted) to the language. So if something more Pythonic exists, I'm pretty sure that it's meant to be used instead of the C++ function equivalent ;)