Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I am having a difficult time trying to understand the Flappy Bird physics. I know it seems simple but I kind of suck at math. I am trying to see if I can make a simple game like this but it is just the dang physics that are throwing me off. I have something like gravity effecting the bird but when you click the screen and I add some amount to the y position but it doesn't look good. You guys have any ideas?

Stuff like:

velocity += -9.8 * Gdx.graphics.getDeltaTime();
position.y += 0.5 * velocity;

That is falling but when I tap the device I would like to know how to add upward force but when it loses it continue falling.

share|improve this question

closed as off-topic by Byte56 Mar 1 at 15:36

  • This question does not appear to be about game development within the scope defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

3  
Show us concrete examples of what you have tried. –  Alex M. Feb 11 at 22:13
    
That code was in the update method and created a realistic fall but don't know how to add upward force. –  G3tinmybelly Feb 11 at 22:22
    
This question appears to be off-topic because it is about how things are done in a specific game –  Byte56 Mar 1 at 15:36
add comment

1 Answer 1

up vote 6 down vote accepted

The bird falls continuously, and when the user taps the screen, it 'jumps' a bit. That's all there is to Flappy Bird's physics.

We use a variable called vertSpeed to keep track of the bird's vertical speed (positive if it goes up, negative if it falls down). jumpSpeed is a positive constant, to which the speed gets reset whenever the user taps the screen. This will immediately make the bird start its ascension. fallingConstant is again a positive constant, which accelerates the bird's decrease in vertical speed on each update. This makes the bird increase in speed when falling.

vertSpeed = 0;

method Update()
{
     if (PlayerTappedScreen)
     {
            vertSpeed = jumpSpeed;
     }
     Position.Y += vertSpeed * deltaTime;
     vertSpeed -= fallingConstant * deltaTime;
}

From here on, all you have to do is experiment with the values, to find a set that works best for you.

share|improve this answer
    
would the falling constant be something that is small or a larger number? –  G3tinmybelly Feb 11 at 22:39
    
Thank you so much! It works! –  G3tinmybelly Feb 11 at 22:43
    
You're welcome :) –  Alex M. Feb 11 at 22:44
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.