Unit 3 Lesson 16 Level 8

Was wondering if anyone has a solution to Level 8 in this lesson.
I have written this so far:
var ghost = createSprite(200,300);

function draw() {
// Wrap the movement lines in two conditionals
if (World.mouseX >= 200) {
ghost.x = ghost.x + 3;
//chick.x = 350;
if ((World.mouseX) < 200) {
ghost.x = ghost.x - 3;


Need help, so the ghost does not move when the mouse is not moving.

Thanks in advance!

Hi @ukolacha,

Let’s try to break down what the question is asking: it says

make the ghost move either left or right depending on the position of the mouse pointer.

So we know that we want the ghost to move right if the mouse is to the right of the ghost, and we want the ghost to move left if the mouse is to the left of the ghost.

We’re also told

  • Write at least two if-statements to check for the location of the mouse.
  • Make the ghost move in a different direction for each mouse location.

So, what two values can we compare to determine whether the mouse pointer is to the left or right of the ghost sprite? Then, based on that, how will that determine the way the ghost moves?

Reply here if you need further assistance with this!

–Michael K.

Thanks for your prompt response. I was able to debug this last night.