[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [pygame] Character Movement
- To: pygame-users@xxxxxxxx
- Subject: Re: [pygame] Character Movement
- From: Luke Paireepinart <rabidpoobear@xxxxxxxxx>
- Date: Tue, 24 Apr 2007 12:03:54 -0500
- Delivered-to: archiver@seul.org
- Delivered-to: pygame-users-outgoing@seul.org
- Delivered-to: pygame-users@seul.org
- Delivery-date: Tue, 24 Apr 2007 13:04:26 -0400
- Dkim-signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:user-agent:mime-version:to:subject:references:in-reply-to:content-type:content-transfer-encoding; b=oZHE6dY4EMIk0KoidWtCCKgmSS33/h444BRRcUe+MFdJ/LAjx/rtPF3SfnhEXRLLTLP7u0ZXYludmM71LokzMsgdlCMIqfA43PRCm4kLZ6CZLcgH2egX6hxs/DDcN5FRC5ro9+ySQUA2Ch+/z6JdR8Vu+A0GyZAqWFrtNOETXeo=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:user-agent:mime-version:to:subject:references:in-reply-to:content-type:content-transfer-encoding; b=D/i2GxowSFaINcqq8OBAgfEEvZh4z2Dc/4UaAjiFnTxKj31QGfTyM2eZ3B465pydf/UHw4Y/iCEfPg5ihJe4/ykgflyCaectiByqBCACoQM0QePBBdH4dnJ/AOQng7PO4BCV5/E4vNaBkqOkUofMyO1jHURt62Vw2S9m5QRD+No=
- In-reply-to: <8c46c7370704240603o6cb5b240h34054c5b5483837c@mail.gmail.com>
- References: <8c46c7370704240603o6cb5b240h34054c5b5483837c@mail.gmail.com>
- Reply-to: pygame-users@xxxxxxxx
- Sender: owner-pygame-users@xxxxxxxx
- User-agent: Thunderbird 1.5.0.10 (Windows/20070221)
Charles Christie wrote:
So, I've finally gotten to the point where I want to make playable
characters controllable. (took me long enough :P )
With that, I'd like to say I am very grateful to you. A few more
questions and I'll be off your back... for this project, at least. ;)
Now then, in my event cue I have it check for key presses. When the
tab button is pressed, the game changes so that the textsprite class
doesn't get any keypresses. The point of this was to make it so that
the character could use buttons on the keyboard to move without
negatively impacting their scores, and that they wouldn't move and
type words at the same time. So, my dillema is this:
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.
It's pretty simple, just add an extra parameter to move that's a boolean
state of that keypress. No reason you have to try to cram all the info
into one argument.
Alternatively, you could just send the event object (you can check if
it's a keypress before you send it so you don't waste time sending
mousemove events to your move function) and just get the event.type out
of the event object in your move function.
Another way would be to abstract the event processing away from the move
function (determining which key is mapped to which button, etc), and
just have the move take in 2 args: an x and a y to move it. Then if you
need to move up or left, just pass in negative values.
HTH,
-Luke