The Daily Click ::. Forums ::. Klik Coding Help ::. Platform Engine Jumping,
 

Post Reply  Post Oekaki 
 

Posted By Message

Kai Proton



Registered
  31/01/2005
Points
  201

Wii Owner
14th March, 2012 at 14/03/2012 20:54:45 -

I know there are loads of engines for this on the web in mmf, and loads of advise on TDC, but IVe looked and looked, and cant find the answer to what I want,

Im making a jump that is like the Super mario jump, ie, the longer the player holds the button, the higher they, jump,


all the examples IVe found are a set jump height that works against the gravity,

this is really getting me annoyed now, because all my first platfomr attepts suffered with this, and now its the other way, I cant get it to do it when I want it to,

K.

 
----------------------
Time for a Sexy Party!
----------------------

Rob Westbrook



Registered
  25/05/2007
Points
  193

360 OwnerVIP Member
15th March, 2012 at 15/03/2012 00:39:48 -

There's an example of this in the platform movement tutorial on the Clickteam website (http://www.clickteam.com/website/usa/tutorials - scroll down to the one by DavidN).

Also the Platform Movement Object can do this, check out the examples that come with the extension

 
There are 10 types of people in the world: Those who understand binary and those who don't.

Windybeard Games



Registered
  14/04/2005
Points
  219

You've Been Circy'd!VIP MemberCandy Cane
15th March, 2012 at 15/03/2012 01:43:56 -

get platform object its very good if your having trouble with custom engines.

 
n/a

Kai Proton



Registered
  31/01/2005
Points
  201

Wii Owner
15th March, 2012 at 15/03/2012 07:32:36 -

I forgot about platform Object,

Ive not used it before,

Thanks I will check it out.


 
----------------------
Time for a Sexy Party!
----------------------

AndyUK

Mascot Maniac

Registered
  01/08/2002
Points
  14586

Game of the Week WinnerSecond GOTW AwardHas Donated, Thank You!VIP Member
16th March, 2012 at 16/03/2012 19:09:27 -

All you need is have something to make the player fall that is unrelated to holding the jump button. Like a flag. Then you have control over it.
so say if the flag is on force the player to fall.

if the player is on the floor turn the flag off
if the player is holding the jump button the flag doesn't change

as soon as the player lets go off the jump button make the flag turn on
if the player has reached their jump's peak, turn the flag on
and if the player isn't standing on the ground turn the flag on

 
.

Fifth

Quadruped

Registered
  07/05/2003
Points
  5818

VIP MemberGOTW JULY 2010 WINNER!Kliktober Special Award TagGOTW HALLOWEEN 2011 WINNERPicture Me This Round 51 Winner!
17th March, 2012 at 17/03/2012 15:50:39 -

My favorite way is, if the player's vertical speed is upwards (whether thats >0 or <0 to you) and the player is not holding the jump button, then divide the player's speed by 2. It's quick enough to respond to be useful, smooth enough to adjust to not look jarring, and really simple to implement.

The biggest problem would come from if your game had other things that would give the player upward speed, like springboards, in which case you'd have to implement a flag to tell the difference between a player's jump and being launched in the air.

 
Go Moon!

Jacob!



Registered
  17/06/2011
Points
  153
21st March, 2012 at 21/03/2012 04:58:28 -

Do you guys seriously force your physics that way? It makes tons more sense to do it in a logical manner. Velocity is just the first derivative of position. That is, change in position over time. Acceleration is the change in velocity over time. I usually set my engines up like this to start:

Always:
--Add X Acceleration to X Velocity
--Add Y Acceleration to Y Velocity
--Add X Velocity to X Position
--Add Y Velocity to Y Position

And it's as simple as that. Setting X Acceleration to 1 will cause the velocity to increase by 1px/frame each frame. To add gravity, just set Y Acceleration to 2,or higher to increase the effects of gravity. You can modify these formulae to account for limits, too. For example, you could replace the second action with Set Y Velocity to min(Y Velocity+Y Acceleration, 10) to force a terminal velocity of 10px/frame.

Using a system like this, it's becomes very easy to manipulate the physics. While jump is held, you can subtract half the gravity value from the Y Acceleration, which will make the jump act as if there is lower gravity while the button is pressed.

 
Have you even been far as decided to use even go want to do look more like?

Jenswa

Possibly Insane

Registered
  26/08/2002
Points
  2723
22nd March, 2012 at 22/03/2012 18:19:29 -

Don't you just love physics.

A button press might set a fixed jump height with a fixed increment.
A button being held might increase the jump height with a fixed increment.

I was gonna use acceleration and speed instead of fixed increment, but perhaps it's better to try getting the button/jump mechanism working with some simple predictable code.

And once the button/jump mechanism is working, try changing it into a jump with speed and acceleration.

The button/jump mechanism for trying out can be as simple as: increasing the y-position while the button is being held with a fixed increment, let's say 4 pixels at a time?

And just like Andy said, you need to check whether the player is still jumping or not. Set or unset a flag upon jumping and landing. That's basically all you need to do. If you change the flag into a variable, you might set a maximum number of jumps the player can make e.g. double jump!

 
Image jenswa.neocities.org
   

Post Reply



 



Advertisement

Worth A Click