[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[pygame] Whats wrong in events?
- To: pygame-users@xxxxxxxx
- Subject: [pygame] Whats wrong in events?
- From: inigo delgado <inigo.delgado@xxxxxxxxx>
- Date: Wed, 7 Oct 2009 21:02:04 +0200
- Delivered-to: archiver@xxxxxxxx
- Delivered-to: pygame-users-outgoing@xxxxxxxx
- Delivered-to: pygame-users@xxxxxxxx
- Delivery-date: Wed, 07 Oct 2009 15:08:37 -0400
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:date:message-id:subject :from:to:content-type; bh=Cb6qdcme64Bja0A/qjp28WrZSpINv7vql5cbzqTIL/M=; b=pYvQ2zvO9xKgY+53NNzoyYCY2l0x/uTx/Egg8aGlAQPluZU21nG1MdJZxJo+bSBfg2 FH46Zx4kj4KT5NtY48LwVJQPhDBQt/SAP+4Hps0zaGtdkHYDIKpAW3QF3j0YgSEKdfJC lTPh6gqtex+KDjT34JTI7s0rEwqBNu6jPq74k=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=fBcdn7Oo0MlXVFiOyOMQmpQcMx32sHjvHes6RbVVoyds0uP5RbzhjjkG38dgXlOhPw 14Oz8o7tlt7odIUEDzs35gKYinrUiFSLxqiCycF/qVUhDVKVuwaeBm2Xn6FF6P74yj2y aNapCDqtPdEk/LrbPy2ZcGN0OnXkgnOE7cVTM=
- Reply-to: pygame-users@xxxxxxxx
- Sender: owner-pygame-users@xxxxxxxx
Hi:
I have a problem capturing K_SPACE keydown events with pygame.
The code is:
.... dirty test code........
def OnEvent(self, event):
if event.type == pygame.QUIT:
self._running = False
else:
self.container.objects[0].doEvent(event)
.... more dirty test code.....
def doEvent(self, event):
print `event`
if event.type == pygame.KEYDOWN:
if event.key == K_SPACE:
self.fire()
elif event.key == K_LEFT:
self.moveX(-1)
elif event.key == K_RIGHT:
self.moveX(1)
elif event.key == K_UP:
self.moveY(-1)
elif event.key == K_DOWN:
self.moveY(1)
elif event.type == pygame.KEYUP:
if event.key == K_LEFT:
self.moveX(1)
elif event.key == K_RIGHT:
self.moveX(-1)
elif event.key == K_UP:
self.moveY(1)
elif event.key == K_DOWN:
self.moveY(-1)
That way, if I push the keys rigth and up at the same time an after the space, the spacecraft shots bullets (executes self.fire()) while going up and to the rigth... but if i press rigth and dow, left an up or left and down an after press fire... the spacecraft don't shot!! -but moves well- O_o Also, the 'print' shows me that no 'keydown' event for space (nor for alt not altgr) is captured when there is no fire....
I have solved it by mapping the fire to another key:
if event.key == K_x:
self.fire()
this way works fine, but i have no idea of what is happening... i'm new in pygame and it can be a knowed issue...
My keyboard is in spanish and my space bar key fires this event:
<Event(2-KeyDown {'scancode': 65, 'key': 32, 'unicode': u' ', 'mod': 4096})>
<Event(3-KeyUp {'scancode': 65, 'key': 32, 'mod': 4096})>
and alt and altgr
<Event(2-KeyDown {'scancode': 64, 'key': 308, 'unicode': u'', 'mod': 4096})>
<Event(3-KeyUp {'scancode': 64, 'key': 308, 'mod': 4096})>
<Event(2-KeyDown {'scancode': 108, 'key': 313, 'unicode': u'', 'mod': 4096})>
<Event(3-KeyUp {'scancode': 108, 'key': 313, 'mod': 4096})>
I have the same problem in my house (ubuntu 9.04) and at work (wXP SP3)