A bit of watching of Flappy Bird provides the following
insights:
- If the bird is travelling upward, it's also looking upward
- If the bird is travelling downward, it starts to rotate its gaze downward
- The longer it's going downward, the more and more it rotates downward
- But there's a maximum amount the bird rotates, no matter how long it's been falling for. It never ends up rotating so far that's "past vertical"
It's actually easier to say in code than in English:
function make_bird_tilt_appropriately() {
if (bird.velocity_y < 0) {
bird.angle= -15; // going up, point up
}
else if (bird.angle < 70) { // max downward tilt is 70 degrees
bird.angle = bird.angle + 4; // going down, point more and more down
}
}
Have a good long look at the English and the Javascript above until you're happy they
both say the same thing.