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

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



If you want the merest touch of the jump key to cause a full strength
jump, just kick up the vertical component of the character's velocity
vector (ensuring of course that the character is not already jumping,
etc) and apply gravity normally.  If you want a longer keypress to
give a higher jump, the way I've always heard of is velocity change,
plus lowering the character's magnitude of gravity during the
keypress.

The big big important bit here is that the character has a velocity
and gets acceleration applied in his update call.  You'll also want
is_jumping and is_airborne flags; the former tells you whether you
should apply the gravity reduction, the latter whether it should be
checking for jump commands.

On Fri, Apr 20, 2012 at 4: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)