Welcome to the CSC Q&A.
Get help and give help!
Write great code!
It is our choices... that show what we truly are, far more than our abilities.

Categories

+9 votes
asked in CSC212_Spring2019 by (817 points)

1 Answer

+3 votes

I'm guessing that your code may be checking if the y coordinate of the bird is exactly equal to a value instead of <= or >=.

For example, when the cardinal is moving up, if the y-coordinate is < Flyable.STEP_SIZE (ie. 5) then another step would put the cardinal out of window at the top and isMovingUp should be set to false. If instead you were checking exactly for a y coordinate of 0 before turning around and the y coordinate of the cardinal is 3, then subtracting 5 would be less than 0 (but not 0), so the y coordinate should throw an exception when you try to use the setPosition method with a y value of -2.

The same can happen at the bottom of the window, checking exactly for Aviary.WINDOW_SIZE or really Aviary.WINDOW_SIZE - Flyable.FLYER_SIZE

answered by (3k points)
...