Skip to content
Advertisement

Flappy bird code not working – JavaScript

I wanted to write a flappy bird game in javascript but it doesn’t seem to work when I open it in my browser. the css works. lines 147, 154, 31 and 160 in js all seem to be errors, but I do not understand how to fix them.

this is my html:

JavaScript
JavaScript

There are many errors in the js when I run it and I can’t seem to understand why. Does anyone know how to fix it?

Advertisement

Answer

One way to solve the problem is to move the event listeners into load and call load in your script:

JavaScript
JavaScript

I replaced poles = document.getElementById("poles") with poles = document.querySelectorAll(".pole") to find all poles.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement