Home | Trees | Indices | Help |
---|
|
1 import time 2 import util.Strings as Strings 3 from operationscore.Input import * 4 import pygame 5 from pygame.locals import * 6 #This class processes input from an already running pygame instance and passes 7 #it to the parent. This class requires an already running pygame instance.9 """PygameInput is an input tied to the PygameDisplay. Specify: 10 <FollowMouse>True</FollowMouse> to receive an input every frame specifying the current mouse 11 position. 12 <Keyboard>True</Keyboard> to grab keystrokes 13 <Clicks>True</Clicks> to grab clicks. 14 15 NB: If follow mouse is enabled, PygameInput will not return mouse and keypresses. You can, however, 16 instantiate other PygameInputs in the XML that will capture mouse and keypresses."""4218 if 'Scale' in self: 19 scale = self['Scale'] 20 else: 21 scale = 1 22 if self['FollowMouse']: 23 self.respond({Strings.LOCATION: pygame.mouse.get_pos()}) 24 return 25 for event in pygame.event.get(): 26 if event.type is KEYDOWN: 27 if event.key == 27: 28 self.die() 29 if self['Keyboard']: 30 try: 31 self.respond({'Key': event.key, 'KeyChar': chr(event.key)}) 32 except: 33 self.respond({'Key': event.key}) 34 return 35 else: 36 pygame.event.post(event) 37 if event.type is MOUSEBUTTONDOWN: 38 if self['Clicks']: 39 self.respond({Strings.LOCATION: pygame.mouse.get_pos()}) 40 else: 41 pygame.event.post(event)
Home | Trees | Indices | Help |
---|
Generated by Epydoc 3.0.1 on Fri Feb 18 16:55:26 2011 | http://epydoc.sourceforge.net |