Smooth platformer jumping


(Elias) #1

Hello!

I run into some difficulties while trying to make my entity accelerate while he jumps up. Can anyone give an advice, example or better a piece of code about acceleration on a fixed timestep?


(Ultima2876) #2

I’m just about to head to bed so I can’t write a detailed explanation at the moment, but I do recommend using a variable timestep (along with FP.elapsed) instead. It will be more stable on lower-end systems and works better if you ever have plans to port to mobile (most mobile games run at 30fps instead of 60fps - if you’ve used a fixed timestep this is a difficult transition to make unless you targeted 30fps originally - with FP.elapsed + variable timestep it’s literally changing one value).

Not sure if it’s subconscious but from my tests variable-timestep games also tend to feel smoother to me, even with both versions running at a solid 60fps. Shrugs


(Elias) #3

That explains a lot to me. I am quite a beginner with FP so i need to collect as much information as i can about… anything. It’s not very complicate to make an entity jump smoothly with a variable timestep. Any tips about it would be appreciated.


(Ultima2876) #4

Check out this demo Chevy Ray made a while ago, it’s useful for getting to grips with the engine and is a platformer:

http://www.mediafire.com/?1n2q5cqk2q67oic [Pink Demo Source]

Unfortunately it went down with the old forums, but I had it on my dropbox so I re-uploaded it!


(Elias) #5

Well, that should do it. Thanks a lot!


(Elias) #6

He used an older version of FP in this demo, isn’t he?


(Ultima2876) #7

That’s true. Are there incompatibilities with the newer versions? I haven’t looked at it in a while. I might spend some time updating it to use the latest version.

Either way if you examine the code you should be able to learn from it!


(Zachary Lewis) #8

I’ve updated the code for FlashPunk 1.7.0. The only major difference was how an Image’s origin was calculated.

You can see the latest code at zachwlewis/pink.


(Elias) #9

Guys, you’re awesome!


(Ultima2876) #10

Ignoring IDEA project files, because they cray.

That made me giggle, @zachwlewis :wink:


(Elias) #11

Sorry for bothering you again…

I followed the demo, (it really helped me a lot) but again… i just cant make my entity jump smoothly. I just don’t get it. The gravity works fine, it got perfect collision with the map but still it just change into a higher position and then smoothly falls down cuz of gravity. Does it need to accelerate? I thought that tweens were used at the demo for the jump. Off-topic but i wanted to ask, when i lunched my code, fps started to fall for an unknown reason and after some mins i lunched again and it was fine. Still does it sometimes… anyone knows the cause or better a solution?


(Zachary Lewis) #12

The tweens are used to control the bounciness and spins of the player while he jumps. You might benifit from reading The Guide To Implementing 2D Platformers. It’s got a lot of good stuff in there.

As far as the frame rate is concerned, it may be having issues connecting to the debugger. In the past that has caused framerate issues for me.