Backwoods Bombardier Trouble

I cannot seem to get my cannon to fire. Here’s the code I’m trying to use, but it’s not making any sense to me. My first problem is that I can’t seem to reveal any of the coordinates I need to bomb. Secondly, my cannon is not getting the commands to fire. Any suggestions to get me going in the right direction?

while (true) {

var enemy = this.findNearestEnemy();
if(enemy) {
    var pos = enemy.pos;
    x = enemy.pos.x;
    y = enemy.pos.y;
    // say the x and y position separated by a comma
    this.say( 62 +"," +51);
    this.say("Fire!");
} else {
    this.say("Cease" + " Fire!");
    this.throw(enemy);
}

}

Is your hero saying anything?

I’m guessing he says ‘Cease Fire!’ then you get an error about needing a target.

You are attempting to throw at an enemy that doesn’t exist. Or does the level start with enemies already on the screen?

1 Like

My hero says “Fire” and the coordinates “62,51”. The 3 enemies are on the screen already.

1 Like

I got it resolved through some troubleshooting and guesswork! My corrections were at the end…

    this.say("Cease" + " Fire!");
 //   this.throw(enemy);
1 Like