Please help with Freeze tag

Zax, please read the other posts in this topic…your issue is identical to the one just resolved.

okay sorry but i just solved that one so i was trying to hek him out

#dedreous You wrote

You need to make game.tagged -= 1 the final statement of the if (other.type == “archer”) loop. Right now, it is the final statement of the if (unit.behavior == “Defends”) loop

Can You more explain this text above?

In Scampers, see how every thing aligns under if (event.other == “player”)?:
image

You need to do the same with Defends…see how it is not lined up?:
image

There are two ways to fix this…either move game.tagged -= 1; up above the circled bracket, or move that bracket below game.tagged.

ok thanks
@CodingGeek14

#dedreous i did what You wrote and igot -55 tagged look at my print screen

But you didn’t do as I explained…let me try a different way.

Position your cursor after the single closing bracket on line 47. Press Enter and type a single closing bracket ‘}’.

Now, see the single closing bracket on line 44? Delete it. If you want, you can click the ‘beautify your code’ button…otherwise, give it a try.

hey, #dedreous I did what You write to me I deleted closing bracket on line 44 and put another one in line 47, but it si still doesnt work, maybe I am still doing something wrong, please help

It looks like you have a mystery closing bracket at the beginning of line 41…delete that one too.

I deleted one from 41 line and put it in the line 47 and it still doesnt work I dont know whats going on

Post your code again…formatted this time, not as a screenshot please.

// Let's make a game of Freeze Tag!
// game.tagged is used to count tagged archers.
game.tagged = 0;
ui.track(game, "tagged");
var goal = game.addManualGoal("Tag all archers.");
// Spawn the archers.
game.spawnXY("archer", 12, 52);
game.spawnXY("archer", 12, 16);
game.spawnXY("archer", 24, 52);
game.spawnXY("archer", 24, 16);
var player = game.spawnPlayerXY('captain', 68, 24);
player.maxSpeed = 40;
// Make the player bigger so it's easier to tag archers.
player.scale = 2;
// Set up the archers' speed and behavior properties onSpawn
function onSpawn(event) {
    var unit = event.target;
    unit.behavior = "Scampers";
    unit.maxSpeed = 8;
}
game.setActionFor("archer", "spawn", onSpawn);
// The event handler for "collide" events.
function onCollide(event) {
    // The event owner who has collided with something.
    var unit = event.target;
    // The object the unit collided with.
    var other = event.other;
    // Use behavior as a marker for the current frozen state.
    // "Scampers" means the archer wasn't yet tagged.
    if (unit.behavior == "Scampers") {
        // If "other" is the player.
        if (event.other == "player") {
            // Set unit.behavior to "Defends":
            unit.behavior = "Defends";
            // Increase game.tagged by 1:
            game.tagged += 1;
        }
    }
    if (unit.behavior == "Defends") {
        // If other's type is "archer":
      if (other.type == "archer") {
            // Set unit.behavior to "Scampers":
            unit.behavior = "Scampers";
       
        // Reduce game.tagged by 1.
        game.tagged -= 1;
        }
}
}
// }
// Use setActionFor to assign onCollide to the "collide" event for "archer"s.
game.setActionFor("archer", "collide", onCollide);
while (true) {
    if (game.tagged >= 4) {
        game.setGoalState(goal, true);
    }
}

I sent you a PM with some code changes…give that a try and let us know.

I run that code You send me and it isnt work, the board is clean no archers and no player :frowning:

Ok, we’re going to need someone else to step in here. For some reason, I can only run that level using Python…I can’t figure out how to switch over to JS. We need someone who can do this to try your code and see what happens.

@Deadpool198 any ideas Danny?

While we’re waiting, have you tried Restarting the level? (You already have a copy of your code saved here, so it is safe).

@dedreous
click game menu then click on change hero then and change your language to javascript and then that should work

There is no ‘change hero’ option, there is only Options.

@dedreous


that’s weird

Exactly…I get this on all 3 of the game dev campaigns…I’m stuck with what ever the level defaults to.

why is that @dedreous