Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: confusion with event handling and timing  (Read 6797 times)

0 Members and 1 Guest are viewing this topic.

grim

  • Guest
confusion with event handling and timing
« 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.

G.

  • Hero Member
  • *****
  • Posts: 1593
    • View Profile
Re: confusion with event handling and timing
« Reply #1 on: August 28, 2014, 03:44:33 am »
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.

grim

  • Guest
Re: confusion with event handling and timing
« Reply #2 on: August 28, 2014, 05:27:48 pm »
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?

G.

  • Hero Member
  • *****
  • Posts: 1593
    • View Profile
Re: confusion with event handling and timing
« Reply #3 on: August 28, 2014, 05:42:06 pm »
I've never used SFML with python so I can't answer you, sorry. :p

grim

  • Guest
Re: confusion with event handling and timing
« Reply #4 on: August 28, 2014, 10:50:40 pm »
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.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: confusion with event handling and timing
« Reply #5 on: August 29, 2014, 07:37:16 am »
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 ;)
Laurent Gomila - SFML developer

 

anything