Need Explanation On Jumping?

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.
Probix
Prole
Posts: 2
Joined: Wed Sep 28, 2016 10:08 am

Need Explanation On Jumping?

Post 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.
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: Need Explanation On Jumping?

Post 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.
User avatar
s-ol
Party member
Posts: 1077
Joined: Mon Sep 15, 2014 7:41 pm
Location: Cologne, Germany
Contact:

Re: Need Explanation On Jumping?

Post 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

s-ol.nu /blog  -  p.s-ol.be /st8.lua  -  g.s-ol.be /gtglg /curcur

Code: Select all

print( type(love) )
if false then
  baby:hurt(me)
end
User avatar
ivan
Party member
Posts: 1915
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: Need Explanation On Jumping?

Post 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
Probix
Prole
Posts: 2
Joined: Wed Sep 28, 2016 10:08 am

Re: Need Explanation On Jumping?

Post by Probix »

So I need to use love.physic? Or is there a different way?
User avatar
Positive07
Party member
Posts: 1014
Joined: Sun Aug 12, 2012 4:34 pm
Location: Argentina

Re: Need Explanation On Jumping?

Post 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)
for i, person in ipairs(everybody) do
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(github.com/pablomayobre)
User avatar
zorg
Party member
Posts: 3465
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: Need Explanation On Jumping?

Post 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.
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
User avatar
Sheepolution
Party member
Posts: 264
Joined: Mon Mar 04, 2013 9:31 am
Location: The Netherlands
Contact:

Re: Need Explanation On Jumping?

Post 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.
User avatar
zorg
Party member
Posts: 3465
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: Need Explanation On Jumping?

Post 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.
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
User avatar
RaycatRakittra
Prole
Posts: 22
Joined: Fri Sep 30, 2016 12:40 am
Location: Chicago, IL
Contact:

Re: Need Explanation On Jumping?

Post 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.
Sometimes, I can code things.
Post Reply

Who is online

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