Jump to content

  • Log In with Google      Sign In   
  • Create Account

#Actualdmreichard

Posted 03 November 2012 - 01:19 PM

An easy way to think about event-based vs polling in this context is being reactive vs proactive, respectively. For example, when you press or release a key this adds an event corresponding to that action in the pygame event queue. One normally retrieves the event queue and then interates through it for events they are interested in capturing. You are therefore reacting to the event.

Polling is the opposite of being reactive. You are basically on each iteration of the game loop saying, "Is this key being pressed right now?" as opposed to "Did this key get pressed?"

There are many resources on the uses and benefits of each, and a google search should turn up useful information.

I found the actual pygame API reference located at http://www.pygame.org/docs/ to be most beneficial versus any tutorial on pygame for explaining the library itself.

#1dmreichard

Posted 03 November 2012 - 01:18 PM

An easy way to think about event-based vs polling in this context is being reactive vs proactive, respectively. For example, when you press or release a key this adds an event corresponding to that action in the pygame event queue. One normally retrieves the event queue and then interates through it for events they are interested in capturing. You are therefore reacting to the event.

Polling is the opposite of being reactive. You are basically on each iteration of the game loop saying, "Is this key being pressed right now?" as opposed to "Did this key get pressed?"

There are many resources on the uses and benefits of each, and a google search should turn up useful information.

I found the actual pygame API reference located at http://www.pygame.org/docs/ to be most beneficial vs any tutorial on pygame for explaining the library itself.

PARTNERS