Lesson 27 Project help please!

My student is trying to have his setEnemy1 (the owl) loop evenly from one side of he screen to the other smoothly but it seems to start in the middle of the screen?

Link to the project or level: [replace with link to the curriculum or get the “Share” link to a project]
What I expect to happen: [replace with a detailed description of the behavior you’re trying to create]
What actually happens: [replace with a detailed description of what actually happens when the code runs including any errors or unexpected behavior]
What I’ve tried: [replace with a detailed description of what you’ve already tried to do to solve the problem]

function setenemy1() {
if (enemy1.x > 400) {
enemy1.y = randomNumber(410, -10);
enemy1.x = randomNumber(-10, 410);
}
}

if the student wants the enemy1(owl) to always reset to just to the left of the screen the 4th line above should be:
enemy1.x = -10;

The line she/he has above is resetting the sprite’s x position to a number in the range of -10 to 410.

In addition, she/he is setting the sprite’s y position to a number in the range of -10 to 410. If the owl should appear on the screen, that should be changed to:
enemy1.y = randomNumber(50,350);

2 Likes