Can anybody figure this out?

There are “birds” that are not showing, there hitboxes are very small but can still kill you. It randomly happens from to to time with no way of controlling it. I don’t know how to fix it.[Debugging Help.]

(Game Lab - Code.org)

The reason the birds don’t show up is because sometimes bird.scale = randomNumber(0.5, 2) returns a value of 0. This means that the bird animation is too small to see, but the hitbox still exists.

It returns 0 because in Game Lab, randomNumber() always returns an integer, never a decimal. You should be able to fix the issue by changing all the scale calls to this:

bird.scale = randomNumber(5, 20) / 10;

By starting with whole numbers and then dividing, you can generate random decimals.

1 Like

Fantastic! I will pass this on to my 7th grader who made this project! Thanks for the speedy reply!