Making the bird jump is easy.
We declare some event listeners for touch, mouse and keyboard, which all call the same function.
It's nice and simple because the game doesn't care where the mouse (or finger) was clicked, just that something happened.
addEventListener("touchstart", Got_Player_Input);
addEventListener("mousedown", Got_Player_Input);
addEventListener("keydown", Got_Player_Input);
And then when we receive some player input, we just
set some upward velocity:
function Got_Player_Input(MyEvent) {
bird.velocity_y = jump_amount;
}
Again, the original
Flappy Bird doesn't do accurate physics, so instead of making the upward jump gradually counteract any existing downward velocity, we just instantly set it moving upward.