[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [pygame] simple examples
On Saturday 09 February 2008 23:59, Ian Mallett wrote:
> This sounds like one of those situations where it would be simpler to just
> write it.
>
> In your event loop:
>
> def GetInput():
> keystate = pygame.key.get_pressed()
> for event in pygame.event.get():
> if event.type == QUIT:
> pygame.quit(); sys.exit()
> if event.type == KEYDOWN:
> if event.key == LEFT: #Move your sprite left.
> elif event.key == RIGHT: #Move your sprite right.
> elif event.key == UP: #Move your sprite up.
> elif event.key == DOWN: #Move your sprite down.
> else: #Make a new sprite.
>
> Or something.
Thanks, but as I understand this will lock the code until a key is pressed?
I am planing to have other sprites "floating", so will need to update them
periodically as well. I don't want to use threads - the task is way too
simple for the hassle.
--
Yours, Mikhail Ramendik