Jump to content

2.5D Beat 'em up jump


Sanju
 Share

Recommended Posts

Hi,

I'm starting to develop a classic style beat 'em up game ("double dragon", "streets of rage"), but I have a problem. I can't figure out how to resolve player's jump. Anybody could point me how to face it or knows a public github project where I could examine some code?

 

Thanks!

Link to comment
Share on other sites

That's a rather generic (unspecific) question :)

Resolve? When a player presses the jump key, just give the sprite an up velocity. If you're using a physics engine and have set gravity, it'll come down eventually... (unless you launched him into orbit :D)

Link to comment
Share on other sites

Yes, I guess I didn't explain myself too clearly :)

I've been thinking on it and, what you say, @Milton, could be a way of implement it. This is an obvious way of doing it in a pure 2D game, but with a 2.5D perspective it requires some more work. I mean, I can set world's gravity and when a button is pressed give the player sprite an up velocity (so far, so good) but now I have to know where to stop sprite's fall in the depth of the scene. In other words, I must know where is the ground (Seeing the next image could be anywhere from the bottom to nearly the middle heigth ).

th?id=OIP.M3f64a7cef9afb5db007590e03812a

I suppose that I should use some kind of invisible shadow sprite beneath the player's character sprite and use collision between these. Or maybe another option could be use some tweening... I'll see

Thanks for your answer

Link to comment
Share on other sites

Interesting. If you don't use physics, it's actually quite easy, because you just set a fixed distance, so you can calculate where the ground will be (simple Pythagoras).
But I would use a 3d physics engine like Bullet (ammo.js), which would make collision checking a lot easier, and would of course solve your problem.

Link to comment
Share on other sites

Streets of rage was such a cool series!

One interesting observation with SoR is that you couldn't jump along the Z-axis (toward/away from the screen) - only along the X-axis. I think this was very much intentional to alleviate some of the issues you are talking about. Watching a few videos, another interesting observation is the shadow beneath the character.

 

I think the simplest approach would be a container, and the arrow keys would control the container - the container could have the shadow (optional - but adds a nice reference to the location of the character when jumping) and the character itself. When you hit the jump key you are moving the character within the container up N pixels and down N pixels. That way you don't need to actually check if he "has landed" or know where the ground it, because the container is always on the ground. 

Referring to the image, red would be the "character" which only moves via the jump key. And green is the container, which moves via the arrow keys

 

 

Untitled-1.jpg

Link to comment
Share on other sites

1 hour ago, Sanju said:

Didn't know about ammo.js. I'll have a look at it, but I think using a 3d engine would be too much for a game like this.

Not a complete 3d engine like Babylon, no rendering is involved. Just a physics replacement for P2 or Ninja. Just use Phaser, include ammo.js, and you're good to go.

Link to comment
Share on other sites

Thank you both for your answers! I Didn't noticed about X-axis restricted jumping in SoR. 

I think @cjke's solution would fit better for some fake Z-axis depth.

Right now I'm doing some experiments with a "shadow" sprite (whitch is what is actually controlled by the player). Every tick, I place the player's sprite on top of it and, when the player wants to jump, I apply gravity and jump acceleration values. Then, when player sprite collides with the shadow, I set gravity to 0 again.

I think this will do the trick.

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...