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

Re: [pygame] [ROOKIE] Best way to manage jump movement



Sounds like you want the first, but just incase, here's both ways. Since both are used in different cases.

[1] For one jump per press:
On the event: KEYDOWN , apply your velocity.

[2] For continual acceleration while holding a key down:
Use pygame.key.get_pressed ( http://www.pygame.org/docs/ref/key.html#pygame.key.get_pressed )

Every X milliseconds you accelerate, while key is down.


On Fri, Apr 20, 2012 at 3:58 PM, NesKy <xavipotrony@xxxxxxxxx> wrote:
Hello everyone,

I've been for some days trying to develop a "canabalt"-like game (http://www.canabalt.com/), saving distances... I've got the way to manage scroll, buildings appearances, distance between them, etc.

Where I'm getting stucked is making the jump movement, and I left this for the last thing to do. What I'm trying to do is a basic jump movement where the more time you're pushing the button the more time you're jumping, with a limit of course. The player is always on the same "x" coordinate, so he only has to change the "y" in the way we want.

So, the way I learned to manage all of this is with a "player" class and some methods to define actions (jump, prone, animation,...). Well, at this point I'm getting frustrated trying to do this with this tools. The only thing I achieve is jumping with the "player" MEANWHILE the key is pressed. And here is the thing: I cannot find the way to make the "player" jump with A TOUCH of a key.

Thanks for your time (and sorry for my English! xD)



--
Jake