Unit 3 Lesson 18 Flybot Game

My student’s code was working that allowed the flybot to fly off the right side and appear on the left. It isn’t working anymore; he said it just stopped working without him making a change, but I don’t know for sure if that’s true. I can’t figure out what is causing the problem.

Please help.

This game looks fun. The problem with the code is on lines 84 and 90. The student cannot have the character.x <= 0. They need to remove “=” and the sprite will fly off to the left.

In this code: The first 2 lines sets the character.x = 0 and the last 2 lines sets the character.x to 400 when the character.x = 0.
if (character.x>400) {
character.x = 0;
}
if (character.x<=0) {
character.x = 400;

1 Like