SFML community forums

Help => General => Topic started by: Mesiow on January 28, 2018, 04:25:51 am

Title: Help with Auto Jumping
Post by: Mesiow on January 28, 2018, 04:25:51 am
This is my first sfml project and I am attempting to make a doodle jump clone but I can't figure out how to make the sprite automatically jump. It just stops in the air after one jump. Any help would be appreciated


This is what my jumping function looks like



void Doodle::Jump(sf::RenderWindow &window)
{
     if(getSpritePos().y > window.getPosition().y)
      {
        mSprite.move(mVelocity);
      }

     if(getSprite().getGlobalBounds().intersects(mBottom.getGlobalBounds()))
      {
          mVelocity.y-=mGravity.y*acceleration.y;
          mSprite.move(mVelocity);

      }

      if(mVelocity.y<=0)
      {
          mVelocity.y=-5.0f;
      }

}


 
Title: Re: Help with Auto Jumping
Post by: eXpl0it3r on January 28, 2018, 11:26:40 am
Looks to me like you're only adjusting the velocity when something happens (collision etc), but gravity pulls on your character even if they're not colliding.