# Help on game development 2 level 22

**URL:** <https://discourse.codecombat.com/t/help-on-game-development-2-level-22/22007>\
**Category:** Level Help\
**Created:** [June 3, 2020, 10:43pm UTC](https://discourse.codecombat.com/t/help-on-game-development-2-level-22/22007 "2020-06-03T22:43:54Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![CHARLES\_CRAWFORD](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/charles_crawford/32/11856_2.png) [@CHARLES\_CRAWFORD](https://discourse.codecombat.com/u/CHARLES_CRAWFORD)\
**Post date:** [June 3, 2020, 10:43pm UTC](https://discourse.codecombat.com/t/help-on-game-development-2-level-22/22007/1 "2020-06-03T22:43:54Z")

</div>

```python
# Let's make a game of Freeze Tag!

# game.tagged is used to count tagged archers.
game.tagged = 0
ui.track(game, "tagged")
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)

player = game.spawnPlayerXY('captain', 68, 24)
player.maxSpeed = 20
# Make the player bigger so it's easier to tag archers.
player.scale = 2

# Set up the archers' speed and behavior properties onSpawn
def onSpawn(event):
    unit = event.target
    unit.behavior = "Scampers"
    unit.maxSpeed = 8

game.setActionFor("archer", "spawn", onSpawn)

# The event handler for "collide" events.
def onCollide(event):
    # The event owner who has collided with something.
    unit = event.target
    # The object the unit collided with.
    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 other == hero:
            # Set unit.behavior to "Defends":
            unit.behavior = "Defends"
            game.tagged +=1
                
        pass
    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.

other.on("collide", onCollide)

while True:
    if game.tagged >= 4:
        game.setGoalState(goal, True)

```

I dont know what im doing wrong. If you spot something I dont please let me know.

---

<div class="post-metadata">

**Author:** ![Redpanda78](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/redpanda78/32/12615_2.png) [@Redpanda78](https://discourse.codecombat.com/u/Redpanda78)\
**Post date:** [June 4, 2020, 8:07pm UTC](https://discourse.codecombat.com/t/help-on-game-development-2-level-22/22007/2 "2020-06-04T20:07:06Z")

</div>

I use JavaScript, not Python, so I might be wrong here; but I would suggest changing your other.on(“collide”, onCollide) to --\> game.setActionFor(“archer”, “collide”, onCollide)

---

<div class="post-metadata">

**Author:** ![dedreous](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/dedreous/32/13849_2.png) [@dedreous](https://discourse.codecombat.com/u/dedreous)\
**Post date:** [June 5, 2020, 2:30pm UTC](https://discourse.codecombat.com/t/help-on-game-development-2-level-22/22007/3 "2020-06-05T14:30:28Z")

</div>

Also, where have you defined ‘hero’?:

```python
    if unit.behavior == "Scampers":
        # If "other" is the player.
        if other == hero:
            # Set unit.behavior to "Defends":
            unit.behavior = "Defends"
            game.tagged +=1

```

---

<div class="post-metadata">

**Author:** ![Thai\_Tr\_n\_Qu\_c](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/thai_tr_n_qu_c/32/28633_2.png) [@Thai\_Tr\_n\_Qu\_c](https://discourse.codecombat.com/u/Thai_Tr_n_Qu_c)\
**Post date:** [April 16, 2022, 11:14am UTC](https://discourse.codecombat.com/t/help-on-game-development-2-level-22/22007/4 "2022-04-16T11:14:38Z")

</div>

# Let’s make a game of Freeze Tag!

# game.tagged is used to count tagged archers.

game.tagged = 0  
ui.track(game, “tagged”)  
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)

player = game.spawnPlayerXY(‘captain’, 68, 24)  
player.maxSpeed = 20

# Make the player bigger so it’s easier to tag archers.

player.scale = 2

# Set up the archers’ speed and behavior properties onSpawn

def onSpawn(event):  
unit = event.target  
unit.behavior = “Scampers”  
unit.maxSpeed = 8

game.setActionFor(“archer”, “spawn”, onSpawn)

# The event handler for “collide” events.

def onCollide(event):  
# The event owner who has collided with something.  
unit = event.target  
# The object the unit collided with.  
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 other == player:  
# Set unit.behavior to “Defends”:  
unit.behavior = “Defends”  
game.tagged +=1

```
    pass
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 archer to the “collide” event for "archer"s.

game.setActionFor(“archer”, “collide”, onCollide)

while True:  
if game.tagged \>= 4:  
game.setGoalState(goal, True)

---

<div class="post-metadata">

**Author:** ![moonwatcher348](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/moonwatcher348/32/24126_2.png) [@moonwatcher348](https://discourse.codecombat.com/u/moonwatcher348)\
**Post date:** [April 16, 2022, 11:27am UTC](https://discourse.codecombat.com/t/help-on-game-development-2-level-22/22007/5 "2022-04-16T11:27:54Z")

</div>

Hi, please format your code correctly using the “preformatted text” button or by using 3 backticks (`) before and after your code
