My ongoing newbie questions

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.
essell
Prole
Posts: 15
Joined: Tue Jun 09, 2009 6:26 pm
Location: Newcastle, UK
Contact:

Re: My ongoing newbie questions

Post by essell »

And another...

I have a physics body as the ground, with the player standing on it. How do I detect whether the player is touching the ground, to determine whether he can jump? Or is there a better way?

(At the moment, the player can keep jumping whilst in the air, as if they're flapping wings and flying upwards...)


[Edit] I've kind of hacked a solution to this, by checking the Y position of the player when they press the jump key, and not making him jump if he's too high. It seems quite crap though - is it more standard to do some kind of collision check between the player and the ground, and base it off that?
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: My ongoing newbie questions

Post by bartbes »

There are going to be callbacks not only when collision starts, but also when it stops, allowing you to use a simple ground boolean, in the mean time:
You can check if 1 pixel below the lowest point is in the ground, in that case, you're on the ground. (use testPoint on the shape)
essell
Prole
Posts: 15
Joined: Tue Jun 09, 2009 6:26 pm
Location: Newcastle, UK
Contact:

Re: My ongoing newbie questions

Post by essell »

Yeah, I've done something similar, cheers.

Q. How do I detect a collision between a bullet and an enemy?
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: My ongoing newbie questions

Post by bartbes »

Create the bullet as a physics entity and just fire it, you do need to set identification data and register a collision callback, but the docs of love.physics should help you with that. So basically it's the same as when you were firing other objects. :P
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 12 guests