[SOLVED] Forest Cannon Dancing JS

The more i make corrections the more the code dose not work.

// Your pet should run back and forth on the X marks.
// The hero should cheer the whole time!

// Write the event function onSpawn for the pet.
// This function should make the wolf run back and forth:
// First, run to the right mark, then the left one:
function onSpawn(event) {
    pet.moveXY(48, 8);
    pet.moveXY(12,8);
}

pet.on("hear", onSpawn);
// Cheer up your pet. Don't remove this:
while (true) {
    hero.say("Run!!!");
    hero.say("Faster!");
}

at first the only problem was that my pet was not happy. Now, the code is all messed up. This was my code before:

// Your pet should run back and forth on the X marks.
// The hero should cheer the whole time!

// Write the event function onSpawn for the pet.
// This function should make the wolf run back and forth:
// First, run to the right mark, then the left one:
while(true) {
    pet.moveXY(48,8);
    pet.moveXY(12,8);

}
// Cheer up your pet. Don't remove this:
while (true) {
    hero.say("Run!!!");
    hero.say("Faster!");
}

Stick with your corrected, original code. This code is valid, just not quite complete:

// Your pet should run back and forth on the X marks.
// The hero should cheer the whole time!

// Write the event function onSpawn for the pet.
// This function should make the wolf run back and forth:
// First, run to the right mark, then the left one:
function onSpawn(event) {
    pet.moveXY(48, 8);
    pet.moveXY(12,8);
}

pet.on("hear", onSpawn);
// Cheer up your pet. Don't remove this:
while (true) {
    hero.say("Run!!!");
    hero.say("Faster!");
}

All that you are missing is the logic needed to determine where the pet needs to move. Something like this:

function onSpawn(event) {
    if pet is at point A {
        then move pet to point B
    }
    otherwise { //pet is already at point B so...
        move pet to point A
    }
}

ok thank you very much

@freshkid006 congragulations on finishing the level remember to mark this as solved

@Jeremy_Yu but I didn’t finish it😐

how, like why???

How what? (20 characters)

u said u did’t solve it

Yes, I did not solve it because its incorrect.

and i dont do javascript

oh how sad, :frowning:

repost your code please…let’s see where you are at now

Right… so if u don’t do Javascript, u won’t know if its correct right?

Im at the same code at the top because every time I tried to make a correction, the code end up being more incorrect.

yes sir …

ok well no need to ask those questions :neutral_face:

In my last (older) post, I recopied what you should be using:

That should now be linked…just replace your current code with that and then take a look at the hint I gave you in that same post.

Ok thank you, ill try it and get back to you.

Ok hope you complete the level

Thank you (20 character)