Jumping Effect (Gravity)

Got a project near completion? Got a project with lots of screens and media? This is the place. This is for nearly finished and Projects with lots of media.
Post Reply
User avatar
Script47
Posts: 147
Joined: Thu Nov 21, 2013 6:11 pm

Jumping Effect (Gravity)

Post by Script47 »

So I decided to try something (which I haven't tried before) I have *attempted* to make gravity/jumping, it can be a big part of quite a few games (I mean who doesn't like jumping). It isn't perfect but I thought it was decent for first attempt. So gimmie your ideas, what you think. And any other advice.

Edit 1:

Any ideas how I could cap the insane jumping time? So user can't just keep hold of it and halo jump forever? I tried a counter but that had unexpected (and quite annoying) results.

http://tests.my-jsgames.tk/
Klown
Posts: 89
Joined: Tue Feb 22, 2011 5:59 am

Re: Jumping Effect (Gravity)

Post by Klown »

Hi - Great example of a jump. If you want to limit the height of the jump to prevent someone from floating up infinitely and/or fly - I would suggest you set a max value for the jump, say 3 or 4x the height of the object or box and once that height is reached force the gravity to take over and drop the object or box.

Hope that idea helps.
if( $myGames != "Crap" ) {
  • please_donate( $money );
} else {
  • just_enjoy();
}
User avatar
vitinho444
Posts: 2819
Joined: Mon Mar 21, 2011 4:54 pm

Re: Jumping Effect (Gravity)

Post by vitinho444 »

When i watched 2d game dev tutorials with Allegro I had the same problem, but they way they fixed on tutorials was to create a bool

Code: Select all

platform = false;
And when press jump check if that is true (meaning the player is in a platform) and if so, put it false and set the jump, then as it is false, you can no longer jump until u reach some kind of floor, so when you collide with the floor always set

Code: Select all

platform = true;
I hope that helps ;)
My Company Website: http://www.oryzhon.com

Skype: vpegas1234
User avatar
Script47
Posts: 147
Joined: Thu Nov 21, 2013 6:11 pm

Re: Jumping Effect (Gravity)

Post by Script47 »

I hope that helps ;)[/quote]
Klown wrote:Hi - Great example of a jump. If you want to limit the height of the jump to prevent someone from floating up infinitely and/or fly - I would suggest you set a max value for the jump, say 3 or 4x the height of the object or box and once that height is reached force the gravity to take over and drop the object or box.

Hope that idea helps.
Thanks for the suggestion, I tried this and failed. :D
vitinho444 wrote:When i watched 2d game dev tutorials with Allegro I had the same problem, but they way they fixed on tutorials was to create a bool

Code: Select all

platform = false;
And when press jump check if that is true (meaning the player is in a platform) and if so, put it false and set the jump, then as it is false, you can no longer jump until u reach some kind of floor, so when you collide with the floor always set

Code: Select all

platform = true;
Yes, I think this is quite a good idea, I shall try this. :)
User avatar
vitinho444
Posts: 2819
Joined: Mon Mar 21, 2011 4:54 pm

Re: Jumping Effect (Gravity)

Post by vitinho444 »

Btw have the gravity act only when platform == false, else the player will just fall through every platform.

Good luck.
My Company Website: http://www.oryzhon.com

Skype: vpegas1234
User avatar
Callan S.
Posts: 2042
Joined: Sun Jan 24, 2010 5:43 am

Re: Jumping Effect (Gravity)

Post by Callan S. »

Yeah, I tend to have it than when the character begins to pass through a platform from gravity, set the character to just above the platform and onplatform=true; And when onplatform==true, gravity does not work and jump is available.

Once they jump, onplatform=false; and gravity is turned on, as well as a short duration timer which gives them lift upwards on the screen that is greater than the gravity.
User avatar
vitinho444
Posts: 2819
Joined: Mon Mar 21, 2011 4:54 pm

Re: Jumping Effect (Gravity)

Post by vitinho444 »

Callan S. wrote:Yeah, I tend to have it than when the character begins to pass through a platform from gravity, set the character to just above the platform and onplatform=true; And when onplatform==true, gravity does not work and jump is available.

Once they jump, onplatform=false; and gravity is turned on, as well as a short duration timer which gives them lift upwards on the screen that is greater than the gravity.
Yeah ;)
My Company Website: http://www.oryzhon.com

Skype: vpegas1234
User avatar
a_bertrand
Posts: 1536
Joined: Mon Feb 25, 2013 1:46 pm

Re: Jumping Effect (Gravity)

Post by a_bertrand »

Personally I would solve the jumping totally different.

When you press the key, and you are on some ground, you put a VY (Vertical Speed) to some negative value. Over the time you add something to the value (+0.01 ?). That will slow down first the going up and then change it with a going down which accelerate and therefore reproduce the gravity.

If you want to allow a double jump you can then implement it as well, and allow 1 jump while not on the ground. The counter would reset when you touch the ground.
Creator of Dot World Maker
Mad programmer and annoying composer
Post Reply

Return to “Project Showoff Tier II”