Jump modulation.

  • 16 Replies
  • 7806 Views
*

Offline just another guy

  • 19
  • 0
  • i need to get a picture soon
    • View Profile
Jump modulation.
« on: March 05, 2009, 21:22:22 »
I have gamemaker, and i am slowly limping my way through my first platformer. But i am having a problem with jump modulation (making the character jump higher depending on how long the 'jump' key is pressed.) I was wondering how other people went about this.

*

Offline LPChip

  • You can only truly help other people by allowing them to fail.
  • 3510
  • 138
  • Excel at the thing you're the best at!
    • View Profile
    • LPChip Interactive
Re: Jump modulation.
« Reply #1 on: March 05, 2009, 21:32:00 »
use both events key-down and key-up. (or how they're called? -pressed -released?)

Do the normal jumping meganism on key down and build in a trigger to abort when a flag is true. On the released, set that flag.

on the left, above my avatar.

MODPlug Central Forum
"If I tried to kill you, I'd end up with a big fat hole through my laptop." - Chironex

*

Offline Kasran

  • 407
  • 6
  • TRANSFENESTRATIVE EGRESS
    • View Profile
Re: Jump modulation.
« Reply #2 on: March 05, 2009, 21:33:22 »
Or, if you're using MMF2, use the Platform Movement Object. :P
grao!

*

Offline just another guy

  • 19
  • 0
  • i need to get a picture soon
    • View Profile
Re: Jump modulation.
« Reply #3 on: March 06, 2009, 00:24:06 »
use both events key-down and key-up. (or how they're called? -pressed -released?)

Do the normal jumping meganism on key down and build in a trigger to abort when a flag is true. On the released, set that flag.



Umm... could you repeat that?  :oops:

*

Offline Shawnachu

  • 223
  • 1
  • Contemplating
    • View Profile
Re: Jump modulation.
« Reply #4 on: March 06, 2009, 00:27:25 »
Or if you are using Construct, use the Platform Behavior.  :P2

*

Offline just another guy

  • 19
  • 0
  • i need to get a picture soon
    • View Profile
Re: Jump modulation.
« Reply #5 on: March 06, 2009, 01:09:57 »
Or, if you're using MMF2, use the Platform Movement Object. :P
Or if you are using Construct, use the Platform Behavior.  :P2

Actually, the prefab stuff was part of what led me away from getting MMF2. I do my own stunts, y'see!  :^^:

but to clarify, i tried getting jump modulation by using a timeline (timeline starts when jump key pressed, timeline ends when jump key released, increase upward speed by a bit for each moment when timeline is active.) This works passably, but it looks a bit artificial. maybe i just have to tweak some of the numbers.

*

Offline LPChip

  • You can only truly help other people by allowing them to fail.
  • 3510
  • 138
  • Excel at the thing you're the best at!
    • View Profile
    • LPChip Interactive
Re: Jump modulation.
« Reply #6 on: March 06, 2009, 12:42:23 »
Normally, you would want to use a sinus for this. But I'm no expert in gamemaker. I have only tried it once, and I know there's scripting in gamemaker. You would want to use the sinus (sin?) to make it look realistic. Basically, for as long as you hold the jump, execute the sin. If released you want to find the current moment in air, and change the sinus to be at its max or near its max on that location. That'll look more natural.
on the left, above my avatar.

MODPlug Central Forum
"If I tried to kill you, I'd end up with a big fat hole through my laptop." - Chironex

*

Offline Kasran

  • 407
  • 6
  • TRANSFENESTRATIVE EGRESS
    • View Profile
Re: Jump modulation.
« Reply #7 on: March 06, 2009, 14:32:35 »
Actually, the prefab stuff was part of what led me away from getting MMF2. I do my own stunts, y'see!  :^^:
Well, you don't have to use the prefab stuff in MMF2. It's just easier.
Besides, the PMO is what Nifflas uses. :>

Also, used correctly the Platform Movement Object is really flexible and can handle a whole lot more than just running and jumping. Take, for example, the climbing in Knytt. All that took was a few extra lines of code.
grao!

*

Offline just another guy

  • 19
  • 0
  • i need to get a picture soon
    • View Profile
Re: Jump modulation.
« Reply #8 on: March 06, 2009, 22:37:53 »
Actually, the prefab stuff was part of what led me away from getting MMF2. I do my own stunts, y'see!  :^^:
Well, you don't have to use the prefab stuff in MMF2. It's just easier.
Besides, the PMO is what Nifflas uses. :>

Also, used correctly the Platform Movement Object is really flexible and can handle a whole lot more than just running and jumping. Take, for example, the climbing in Knytt. All that took was a few extra lines of code.

Yeah. i don't doubt that MMF2 could give me all the flexibility i need. i guess it's just this hangup i have, which is ironic because if i really didn't like prefab tools, i would have to actually learn real programming and not just buy gamemaker.  :/

Don't question my logic! :crazy:

*

Offline Kasran

  • 407
  • 6
  • TRANSFENESTRATIVE EGRESS
    • View Profile
Re: Jump modulation.
« Reply #9 on: March 06, 2009, 22:56:29 »
Actually, the prefab stuff was part of what led me away from getting MMF2. I do my own stunts, y'see!  :^^:
Well, you don't have to use the prefab stuff in MMF2. It's just easier.
Besides, the PMO is what Nifflas uses. :>

Also, used correctly the Platform Movement Object is really flexible and can handle a whole lot more than just running and jumping. Take, for example, the climbing in Knytt. All that took was a few extra lines of code.

Yeah. i don't doubt that MMF2 could give me all the flexibility i need. i guess it's just this hangup i have, which is ironic because if i really didn't like prefab tools, i would have to actually learn real programming and not just buy gamemaker.  :/

Don't question my logic! :crazy:
MMF2 is more powerful than Game Maker. :moody:
grao!

*

Offline Shawnachu

  • 223
  • 1
  • Contemplating
    • View Profile
Re: Jump modulation.
« Reply #10 on: March 06, 2009, 23:01:46 »
And Construct, but IMHO Construct is better than GM. If you don't like the prefab, then you can Python script.

EDIT: But if you really want to use GM, then you can say:

On Key down: set vertical speed to (blah)
                       set timer(blah) to (blah)
On key release: set vertical speed to (0)
                         turn timer off
On Timer is up: set vertical speed to (0)

Basically, when you let go of the key, you start falling, but when the timer gets to 0, then you also start falling. But, turning off the timer means that you don't fall, then stop falling, then fall again.
« Last Edit: March 06, 2009, 23:05:17 by shawnachu »

*

Offline Mr. Monkey

  • 222
  • 1
  • jolly good fellow
    • View Profile
Re: Jump modulation.
« Reply #11 on: March 06, 2009, 23:06:03 »
And Construct, but IMHO Construct is better than GM. If you don't like the prefab, then you can Python script.
But the Python interpreter is prefab :P
o__  o

*

Offline LPChip

  • You can only truly help other people by allowing them to fail.
  • 3510
  • 138
  • Excel at the thing you're the best at!
    • View Profile
    • LPChip Interactive
Re: Jump modulation.
« Reply #12 on: March 07, 2009, 01:27:00 »
Guys, lets not discuss which program is better! This topic is about game maker. If you don't know it, then don't get involved.
on the left, above my avatar.

MODPlug Central Forum
"If I tried to kill you, I'd end up with a big fat hole through my laptop." - Chironex

*

Offline Rhyok

  • 13
  • 0
    • View Profile
Re: Jump modulation.
« Reply #13 on: March 12, 2009, 06:23:28 »
Quick question before I give a much more complicated answer, involving my experiences in physics, trigonometry, algebra, and past coding experiences: Are you making your own physics engine or are you using the simple gravity simulation included with Game Maker?

shawnachu gave the correct answer in the latter case, and the method he told you is what most games use today: stop moving upwards when you release the jump button.

PHYSICS ALERT: All you're doing is applying an initial force to an object (measured in Game Maker's arbitrary units of "vspeed") and then Game Maker does the rest of the intermediate calculations. The only way to go about essentially modifying gravity in mid-air is to do just that: modify gravity in mid-air (this would look awkward) or to set your upwards movement to 0 and let Game Maker accelerate you back to the ground. On the other hand, if you were to code all your own jumps (sounds like a t-shirt), you could modify the motion in-flight as LPChip suggests by using sine to determine the y-position of your character.

To highlight a flaw in shawnachu's idea: what happens if you are moving down and the timeline is marching on? You COULD use a timeline, or you could do this:

Code: [Select]
Key Press event:
vspeed = some number
Key Release event:
if(vspeed > 0){
vspeed = 0
};
Since the key press event is called only when a key is pressed, you get the initial burst of force upwards which is slowed down (and eventually sped up in the opposite direction) by Game Maker gravity. Bounds more simple than the way everyone else is suggesting, and, in theory, should work.

As I said, tell me what method you are using. By the sounds of it, you ARE using the Game Maker gravity. If you are coding gravity itself, I can help you there too.

*

Offline Krumel

  • 33
  • 0
  • One can be dividided by Zero!
    • View Profile
Re: Jump modulation.
« Reply #14 on: March 12, 2009, 18:07:43 »
I would use a squarish (is it written like that?) function.
Maybe something like (-(x-1)?+1)*n , where x is a time factor and n is the time the jump button was pressed.