[SOLVED]Can I have help with forest cannon dancing

This is my code so far:

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:

Fir, then the left one:

hero.buildXY(“bear-trap”, 54, 18)
onSpawn = pet.moveXY (48, 8)
OnSpawn = pet.moveXY (12, 8)
while True:
hero.say(“Run!!!”)
hero.say(“Faster!”)
if “bear-trap”:
pet.moveXY(48, 8)
pet.moveXY(12, 8)

1 Like

Hello and welcome to codecombat discourse! This is a cozy forum where you can share ideas, share fan art, get assistance for code, etc! Before you proceed, we hope that you review this topic, which shows all essentials of this board! Thanks!

1 Like

please format your code by using this and pasting your code inside image

Hello and welcome to codecombat discourse! This is a cozy forum where you can share ideas, share fan art, get assistance for code, etc! Before you proceed, we hope that you review this topic, which shows all essentials of this board! Thanks!

1 Like

Welcome to the forum @codeneedhelp! please read the topic through the link that @milton.jinich and @Falcons118 gave you. And like @Falcons118 said, before we can help you, you need to format your code correctly. when copying it down to the discourse, use this button, and it will look like the code on codecombat!
format code
hope this helps!
~Andrew

1 Like

You have the code saying if bear trap, then run, but you haven’t defined bear trap. The pet on spawn should be written like this

def onSpawn(event):
    #have the pet run around
pet.onSpawn(onSpawn, event)
While True:
    #have the hero cheer

I’m on my phone rn so I can’t double check the on spawn code, but I’m pretty sure it’s good

2 Likes

Did that when I joined.

2 Likes

Can you format your code I can help you after

1 Like

Do you mean copy and paste?

1 Like

I’ll format it.
20 chars

1 Like

hero.buildXY(“bear-trap”, 54, 18)
onSpawn = pet.moveXY (48, 8)
OnSpawn = pet.moveXY (12, 8)
while True:
    hero.say(“Run!!!”)
    hero.say(“Faster!”)
    if “bear-trap”:
        pet.moveXY(48, 8)
        pet.moveXY(12, 8)


Ok, first of all your quotes(These "") are wrong and second maybe you should try to restart the level and read the comments carefully.

1 Like

Ummm I tried that it just didn’t work.

1 Like

try using english quotes not the chinese ones(english quote: " ")

Refresh all your code. Then define the onSpawn() function. Within the function, you need to command your pet to move to two points, but the pet has to move forever, so you have to make your pet move to the two points within a while true loop.

def onSpawn():
    # while true loop:
        # command your pet to move to the two points

That is all you have to write.

1 Like

Thank you so much!!! It really helped a lot

3 Likes

if its solved mark the post that helped the most as solved.

3 Likes

Yes there should be a “Solution” box at the bottom right corner of a post. Tick that box on the post that helped you the most.

2 Likes
// Your pet should run back and forth on the X marks.
// The hero should cheer the whole time!
auto onSpawn(auto event){
    while(true) {
        pet.moveXY(48, 8);
        pet.moveXY(12, 8);
    }
}
int main() {
    // 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:
    
       
    
    
    pet.on("spawn", onSpawn);
    // Cheer up your pet. Don't remove this:
    while (true) {
        hero.say("Run!!!");
        hero.say("Faster!");
        onSpawn();
    }
    
    return 0;
}

I can not seem to see what is wrong. i am working with C++. any help would be awesome thanks