Re: [pygame] raw_input() and pygame.event.get()

2006-12-11 Thread Mike Wyatt

Mike Wyatt wrote:

Pete Shinners wrote:

On Sun, 2006-12-10 at 22:12 -0600, Mike Wyatt wrote:
 

Oops, I forgot to mention that.  I'm using raw_input() because I want
to focus on getting my game working before putting time into writing a
GUI.  Without a GUI, the only way I can get user input is with
raw_input().  I'm working on my networking code, so I need to have
each game instance ask the user (i.e. myself) to host a new game or
join an existing game.



Use the pygame event filtering to block certain event types. Turn this
off and on around your input_raw call.

http://pygame.org/docs/ref/event.html#pygame.event.set_blocked

pygame.event.set_blocked(pygame.KEYDOWN | pygame.KEYUP)
value = raw_input()
pygame.event.set_blocked(None)



  
That code doesn't block the events.  They still appear in the next 
call to pygame.event.get().  Here is a script you can run to verify this:


*
import pygame

pygame.init()
displaySurface = pygame.display.set_mode( (400, 300), 0 )

while True:

   for event in pygame.event.get():
   print event
   if event.type == pygame.KEYDOWN and event.key == pygame.K_s:
   pygame.event.set_blocked(pygame.KEYDOWN | pygame.KEYUP)
   value = raw_input("Type some stuff (include the 's' 
character): ")

   pygame.event.set_blocked(None)
   print "You typed", value
   pygame.display.flip()
*


pygame.display.flip() didn't have the appropriate indentation.  It 
should be corrected now (above).  Has anyone run this and confirmed my 
problem?


Re: [pygame] raw_input() and pygame.event.get()

2006-12-10 Thread Mike Wyatt

Pete Shinners wrote:

On Sun, 2006-12-10 at 22:12 -0600, Mike Wyatt wrote:
  

Oops, I forgot to mention that.  I'm using raw_input() because I want
to focus on getting my game working before putting time into writing a
GUI.  Without a GUI, the only way I can get user input is with
raw_input().  I'm working on my networking code, so I need to have
each game instance ask the user (i.e. myself) to host a new game or
join an existing game.



Use the pygame event filtering to block certain event types. Turn this
off and on around your input_raw call.

http://pygame.org/docs/ref/event.html#pygame.event.set_blocked

pygame.event.set_blocked(pygame.KEYDOWN | pygame.KEYUP)
value = raw_input()
pygame.event.set_blocked(None)



  
That code doesn't block the events.  They still appear in the next call 
to pygame.event.get().  Here is a script you can run to verify this:


*
import pygame

pygame.init()
displaySurface = pygame.display.set_mode( (400, 300), 0 )

while True:

   for event in pygame.event.get():
   print event
   if event.type == pygame.KEYDOWN and event.key == pygame.K_s:
   pygame.event.set_blocked(pygame.KEYDOWN | pygame.KEYUP)
   value = raw_input("Type some stuff (include the 's' 
character): ")

   pygame.event.set_blocked(None)
   print "You typed", value
  
   pygame.display.flip()

*



Re: [pygame] raw_input() and pygame.event.get()

2006-12-10 Thread Pete Shinners
On Sun, 2006-12-10 at 22:12 -0600, Mike Wyatt wrote:
> Oops, I forgot to mention that.  I'm using raw_input() because I want
> to focus on getting my game working before putting time into writing a
> GUI.  Without a GUI, the only way I can get user input is with
> raw_input().  I'm working on my networking code, so I need to have
> each game instance ask the user (i.e. myself) to host a new game or
> join an existing game.

Use the pygame event filtering to block certain event types. Turn this
off and on around your input_raw call.

http://pygame.org/docs/ref/event.html#pygame.event.set_blocked

pygame.event.set_blocked(pygame.KEYDOWN | pygame.KEYUP)
value = raw_input()
pygame.event.set_blocked(None)




Re: [pygame] raw_input() and pygame.event.get()

2006-12-10 Thread Richard Jones
On Monday 11 December 2006 15:12, Mike Wyatt wrote:
> Oops, I forgot to mention that.  I'm using raw_input() because I want to
> focus on getting my game working before putting time into writing a
> GUI.  Without a GUI, the only way I can get user input is with
> raw_input().  I'm working on my networking code, so I need to have each
> game instance ask the user (i.e. myself) to host a new game or join an
> existing game.
>
> Does that make sense?

Kinda :)

So I guess you just have to make sure you're focusing either on the pygame 
window (to send it events) or the shell that launched the pygame app (to send 
events to raw_input). If that works, which I couldn't guarantee.


Richard