Failure to Jump

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
aliceandsven
Prole
Posts: 13
Joined: Thu Mar 29, 2012 3:15 pm

Failure to Jump

Post 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
Attachments
platforming.love
(2.2 KiB) Downloaded 101 times
Projects: 1) shape story xiv: fabula nova questalis [mouse-avoid game]
User avatar
tentus
Inner party member
Posts: 1060
Joined: Sun Oct 31, 2010 7:56 pm
Location: Appalachia
Contact:

Re: Failure to Jump

Post 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
Kurosuke needs beta testers
User avatar
aliceandsven
Prole
Posts: 13
Joined: Thu Mar 29, 2012 3:15 pm

Re: Failure to Jump

Post by aliceandsven »

Trying this now

EDIT: Thanks it worked!!
Projects: 1) shape story xiv: fabula nova questalis [mouse-avoid game]
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Failure to Jump

Post by bartbes »

Personally, I would test for the direction of movement, and only register as landed when there's downward motion.
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 220 guests