Sanju Posted April 30, 2016 Share Posted April 30, 2016 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 More sharing options...
Milton Posted April 30, 2016 Share Posted April 30, 2016 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 ) Sanju 1 Link to comment Share on other sites More sharing options...
Sanju Posted April 30, 2016 Author Share Posted April 30, 2016 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 ). 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 More sharing options...
Milton Posted April 30, 2016 Share Posted April 30, 2016 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. Sanju 1 Link to comment Share on other sites More sharing options...
Sanju Posted May 1, 2016 Author Share Posted May 1, 2016 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. Thanks! Link to comment Share on other sites More sharing options...
cjke Posted May 1, 2016 Share Posted May 1, 2016 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 Sanju 1 Link to comment Share on other sites More sharing options...
Milton Posted May 1, 2016 Share Posted May 1, 2016 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. Sanju 1 Link to comment Share on other sites More sharing options...
Sanju Posted May 1, 2016 Author Share Posted May 1, 2016 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. cjke 1 Link to comment Share on other sites More sharing options...
cjke Posted May 1, 2016 Share Posted May 1, 2016 Nice. Goodluck and let us know how you go! Link to comment Share on other sites More sharing options...
Recommended Posts