The program is saying the only thing I haven’t done is cheer up my pet which I have no idea how to do. What should I do now?
// 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!");
}
// Your pet should run back and forth on the X marks.
// The hero should cheer the whole time!
function onSpawn();
// 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);
pet.moveXY(48,8);
pet.moveXY(12,8);
// Cheer up your pet. Don't remove this:
while (true) {
hero.say("Run!!!");
hero.say("Faster!");
}
// 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);
}
pet.on("spawn", onSpawn);
// Cheer up your pet. Don't remove this:
while (true) {
hero.say("Run!!!");
hero.say("Faster!");
}
// 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);
}
onSpawn();
pet.on("spawn", onSpawn);
// Cheer up your pet. Don't remove this:
while (true) {
hero.say("Run!!!");
hero.say("Faster!");
}
// 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("spawn", onSpawn);
// Cheer up your pet. Don't remove this:
while (true) {
hero.say("Run!!!");
hero.say("Faster!");
}
It looks mostly good now, except your pet is trying to listen for your encouragement. In the ‘pet.on’ statement, you want “hear” instead of “spawn”.
Also, in the onSpawn function, you need to add logic to determine which X the pet is currently at; once this is determined, have him run to the other X. A simple if/else if statement should work fine.