Package pygsear :: Module Event
[show private | hide private]
[frames | no frames]

Module pygsear.Event

Keyboard and mouse event handling.

This module is used to create objects that relate raw pygame events (keys being pressed on the keyboard, mouse buttons being clicked, the pygame window being closed, joystick movement (incomplete)) with other object methods and functions.

For instance, in your game you may want to use a control where every time the up arrow is pressed on the keyboard, your player's ship starts to accelerate. That might look something like:
   class Ship:
       def initialize(self):
           self.events.add(Event.KEYDOWN_Event(key=K_UP, callback=self.accel))
Actually controlling the ship is a bit more complicated than this, since you probably want the player to be able to hold down the arrow to keep on accelerating. See some of the examples for more ideas on how to do that.
Classes
Event Relates Pygame Events with related actions.
EventGroup Used to group related events.
KEY_Event Keyboard events.
KEYDOWN_Event  
KEYUP_Event  
MOUSEBUTTON_Event Mouse button events.
MOUSEBUTTONDOWN_Event  
MOUSEBUTTONUP_Event  
QUIT_Event  
Repeat_KEY_Event KEY_Event which will auto-repeat after a delay.
TIMEOUT_Event  

Variable Summary
int K_LALT
int K_LCTRL
int K_LSHIFT
int K_RALT
int K_RCTRL
int K_RSHIFT
int KEY
int KEYDOWN
int KEYUP
list MODIFIERS
int MOUSEBUTTON
int MOUSEBUTTONDOWN
int MOUSEBUTTONUP
int QUIT
int TIMEOUT

Variable Details

K_LALT

Type:
int
Value:
308                                                                    

K_LCTRL

Type:
int
Value:
306                                                                    

K_LSHIFT

Type:
int
Value:
304                                                                    

K_RALT

Type:
int
Value:
307                                                                    

K_RCTRL

Type:
int
Value:
305                                                                    

K_RSHIFT

Type:
int
Value:
303                                                                    

KEY

Type:
int
Value:
-2                                                                     

KEYDOWN

Type:
int
Value:
2                                                                      

KEYUP

Type:
int
Value:
3                                                                      

MODIFIERS

Type:
list
Value:
[304, 303, 306, 305, 308, 307]                                         

MOUSEBUTTON

Type:
int
Value:
-4                                                                     

MOUSEBUTTONDOWN

Type:
int
Value:
5                                                                      

MOUSEBUTTONUP

Type:
int
Value:
6                                                                      

QUIT

Type:
int
Value:
12                                                                     

TIMEOUT

Type:
int
Value:
-1                                                                     

Generated by Epydoc 1.1 on Sun Jan 25 19:10:09 2004 http://epydoc.sf.net