Page 1 of 1

Failure to Jump

Posted: Sun Apr 01, 2012 11:35 pm
by aliceandsven
Hello.

I've been trying to get the basics down of creating a simple player movement engine for a 2d platformer, following a tutorial: http://www.explodingrabbit.com/forum/en ... al-01.669/

My box CAN move left and right along the floor BUT HE WON'T JUMP and after almost and hour of just checking the code and seeing what could be wrong I can't figure this out. I'm at my wits end. Everything seems right but he won't friggin' jump.

Please, if anyone with a keener mind could take a look and see if something is wrong, I would appreciate it greatly!

the mechanics are stored in player.lua but maybe something (somehow?!) is not agreeing elsewhere in the other .luas!?

go left = a
go right = d
jump = SUPPOSED TO BE j

Re: Failure to Jump

Posted: Mon Apr 02, 2012 12:36 am
by tentus
You check to see if they have landed immediately after you check if they pushed the jump button. Hence, they are landing before they get off the ground.

To fix it, add "self.y = self.y - 1" between lines 39 and 40. This way they get off the ground before being told Velocity = 0

Re: Failure to Jump

Posted: Mon Apr 02, 2012 12:46 am
by aliceandsven
Trying this now

EDIT: Thanks it worked!!

Re: Failure to Jump

Posted: Mon Apr 02, 2012 6:59 am
by bartbes
Personally, I would test for the direction of movement, and only register as landed when there's downward motion.