Page 1 of 2

Need Explanation On Jumping?

Posted: Mon Oct 03, 2016 2:53 am
by Probix
I'm new to LOVE Engine and would like to know how to go about making a square jumping by pressing the space bar. Is there a video of it? Any tutorial at all? I can't seem to find much about it.

Re: Need Explanation On Jumping?

Posted: Mon Oct 03, 2016 7:32 am
by raidho36
First you need to understand what you're doing. The act of jumping is fundamentally going upwards. That is having velocity that is upwards, that continuously affects position, which then also changes to a higher point. So, to jump, you need to give the body upwards velocity. Then, jumping is conventionally impossible without having something to push yourself off of, that is solved with collision detection systems, the object must be in contact with some surface. And finally, you probably need gravity, that is vertical velocity component must continuously increase - as long as the object is in a complete free-fall anyway.

Re: Need Explanation On Jumping?

Posted: Mon Oct 03, 2016 8:35 am
by s-ol
like raidho36 said, you will need to first understand the basic physics concepts, there's tons of material like this: https://www.youtube.com/watch?v=ZnWP5h69DBM

Re: Need Explanation On Jumping?

Posted: Mon Oct 03, 2016 11:43 am
by ivan
raidho36 wrote:The act of jumping is fundamentally going upwards.
Yes, you're in the right direction. I would say jumping is more like throwing a rock - the "initial velocity" determines the high of the throw. As soon as the rock leaves your hand only gravity and air resistance affect its flight.
Of course in games there are many additional tricks like double-jumping and jump termination which do not follow the laws of physics:
http://2dengine.com/doc/gs_platformers.html

Re: Need Explanation On Jumping?

Posted: Tue Oct 04, 2016 10:37 pm
by Probix
So I need to use love.physic? Or is there a different way?

Re: Need Explanation On Jumping?

Posted: Wed Oct 05, 2016 12:33 am
by Positive07
You need to understand physics, the [wiki]love.physic[/wiki] module already handles all the math so if you use that you need to learn that. But you can do physics without that module. Is just math after all, but if you don't know about this math you can check out the already mentioned tutorials, or use the love.physics module or a similar library (like bump.lua)

Re: Need Explanation On Jumping?

Posted: Wed Oct 05, 2016 9:49 am
by zorg
Another good thing one should understand is the difference between how a human would jump, vs. how mario jumps, for instance.
It doesn't take a physics lib to code a more "gameistic" jump solution.

Re: Need Explanation On Jumping?

Posted: Wed Oct 05, 2016 11:36 am
by Sheepolution
s-ol wrote:like raidho36 said, you will need to first understand the basic physics concepts, there's tons of material like this: https://www.youtube.com/watch?v=ZnWP5h69DBM
This isn't advice you should give to a beginner, as a 36 minute long video of this can be quite discouraging and makes programming look harder than it is.

Re: Need Explanation On Jumping?

Posted: Wed Oct 05, 2016 2:09 pm
by zorg
Sheepolution wrote:
s-ol wrote:like raidho36 said, you will need to first understand the basic physics concepts, there's tons of material like this: https://www.youtube.com/watch?v=ZnWP5h69DBM
This isn't advice you should give to a beginner, as a 36 minute long video of this can be quite discouraging and makes programming look harder than it is.
In my opinion, it can also build character! :D
But seriously, if i were to ask for help regarding any topic, even if i would receive stuff way above my head, i'd save those reference materials for later when i would understand them. That's just me though.

Re: Need Explanation On Jumping?

Posted: Wed Oct 05, 2016 10:17 pm
by RaycatRakittra
Sheepolution wrote:
s-ol wrote:like raidho36 said, you will need to first understand the basic physics concepts, there's tons of material like this: https://www.youtube.com/watch?v=ZnWP5h69DBM
This isn't advice you should give to a beginner, as a 36 minute long video of this can be quite discouraging and makes programming look harder than it is.
Agreed. As long as OP knows what jumping looks like and that gravity is a constant pulling force (unless they've disabled it on the ground for some reason), they'll be fine.

Keep at it! You can do it. Study some .love files and emulate how they do things.

EDIT: Try this: http://lovefiddle.com/gAfgmqzs6Ld7gWamf

Courtesy of that LOVE fiddle thread in General.