开发者

Arc'd jumping method?

Okay, so I'm making a platformer, and I wanna know how I can make a arc'd jump easily. Like what Mario does in super Mario Bros开发者_JS百科 1. Any ideas on a simple way to accomplish this?


Simulate gravity ^^

you mario will have a delta to control its move on X, then make it 2D vect that will include a Y componnent this Y will always have a -gravity add to the vertical acceleration.

this way when your jumping you'll have the forward the jumping force+the gravity that will progressively drag mario back down giving you your arc


Pretty simple pseudo code:

if playerHitsGround or playerHitsBlockAbove:
   playerGravity = 0 // reset the gravity
endif

if jumpButtonHit and playerGravitiy == 0:
    playerGravity = -5 // set the "negative" gravity
endif

playerGravity += 0.1 // increase the gravity, so we fall back
playerPositionY += playerGravity // apply our "gravity" to the player

That's as simple as you can get, and most likely also the same method that was used back in the NES days. The "arc" here comes from the fact that while the "gravity" is being applied, you also move forward.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜