[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Character Movement



Charles Christie wrote:
I send the event.unicode to the move function, which makes the character move. However, I don't think I can use event.unicode to send keyup events. So that means when the person presses the button to move, when they release the button they won't stop moving. That's a Very Bad Thing. If you want to see my (really badly written) code I can send it if you want it.

Hi. I'm not sure whether this is what you mean, but are you reading KEYDOWN and KEYUP events, or just using pygame.key.get_pressed() to see what keys are pressed at any given moment? If you use KEYDOWN and/or KEYUP you can respond only once to each keypress.


(That is: "for event in pygame.event.get: if event.type == KEYDOWN: if event.key == K_a: blah blah...")

You're the one doing the typing action game, right? I found it was best, for a typing interface, to use KEYDOWN events plus a checking of get_pressed (to see whether a shift key was down) to decide what character the user actually wanted to type.

Got any screenshots?

Kris