Jumping Physics

Posted by CogWheelz on Game Development See other posts from Game Development or by CogWheelz
Published on 2014-08-23T15:50:42Z Indexed on 2014/08/23 16:34 UTC
Read the original article Hit count: 172

Filed under:
|
|

With simplicity, how can I make a basic jump without the weird bouncing? It jumps like 2 pixels and back

Here's what I use

y += velY
x += velX

then keypresses

 MAX_SPEED = 180;
 falling = true;
if(Gdx.input.isKeyPressed(Keys.W)) {//&& !jumped && !p.falling) {
        p.y += 20;


    }

    if(!Gdx.input.isKeyPressed(Keys.W))
        p.velY = 0;

    if(Gdx.input.isKeyPressed(Keys.D))
        p.velX = 5;

    if(!Gdx.input.isKeyPressed(Keys.D) && !(Gdx.input.isKeyPressed(Keys.A)))
        p.velX = 0;

    if(Gdx.input.isKeyPressed(Keys.A))
        p.velX = -5;

    if(!Gdx.input.isKeyPressed(Keys.A) && !(Gdx.input.isKeyPressed(Keys.D)))
        p.velX = 0;


    if(p.falling == true || p.jumping == true) {
        p.velY -= 2;


    }

    if(p.velY > MAX_SPEED)
        p.velY = MAX_SPEED;

    if(p.velX > MAX_SPEED)
        p.velX = MAX_SPEED;

© Game Development or respective owner

Related posts about java

Related posts about physics