Unit 3 Lesson 18

Can someone help debug this? The bear should continue moving back along the x axis when it reaches bear.x>350 it should turn and go back the other way. It turns, but doesn’t move. What am I missing!?

Once it reaches 350, it does turn and moves back two steps which makes it less than 350, so it then wants to move right … and it hits 350 and then it goes back to 348 and is in a forever loop.

You’ll probably need to create some kind of a boolean variable to track the direction of the bear. Then, if he’s facing right, he moves forward but if facing left, he moves to the left …

In other words, reaching 350 should trigger the boolean which sets the direction rather than using two logic statements that will constantly play against each other.

If that doesn’t make sense, please reach back out and I’ll try to be a little more clear.

Good luck!