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.

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

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.

  • \$\begingroup\$ would the falling constant be something that is small or a larger number? \$\endgroup\$ – G3tinmybelly Feb 11 '14 at 22:39
  • \$\begingroup\$ Interesting. I started to teach my stepson how he could "make a game from scratch" this week (using Processing and a bounding ball), and I was giving the bird a fixed impulse vertSpeed += speedIncrement and upon playing he immediately complained of the behaviour. When I started to assign vertSpeed to a fixed speedIncrement (or jumpSpeed if you want), he then instantly recognizes the actual FlappyBird "feel". \$\endgroup\$ – heltonbiker Apr 15 '16 at 20:20

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