Game Dev. 2 Final Project Help


#1

For some reason, (it dosen’t say which line) it says "cannot read property ‘start’ of undefined. Here is my code. It’s pretttty long.

# Create your own game!
def onSpawn(event):
    unit = event.target
    while True:
        enemy = unit.findNearestEnemy()
        if enemy:
            unit.attack(enemy)
game.setActionFor("scout", "spawn", onSpawn)
game.setActionFor("ogre", "spawn", onSpawn)
game.setActionFor("soldier", "spawn", onSpawn)
game.setActionFor("archer", "spawn", onSpawn)
# Spawn a player with spawnPlayerXY()
game.spawnXY("scout", 60, 58)
game.spawnXY("scout", 28, 29)
game.spawnXY("scout", 61, 24)
game.spawnXY("scout", 60, 58)
game.spawnXY("scout", 28, 29)
game.spawnXY("scout", 61, 24)
game.spawnXY("scout", 60, 58)
game.spawnXY("scout", 28, 29)
game.spawnXY("scout", 61, 24)
game.spawnXY("scout", 60, 58)
game.spawnXY("scout", 28, 29)
game.spawnXY("scout", 61, 24)
game.spawnXY("scout", 60, 58)
game.spawnXY("scout", 28, 29)
game.spawnXY("scout", 61, 24)
game.spawnXY("scout", 60, 58)
game.spawnXY("scout", 28, 29)
game.spawnXY("scout", 61, 24)
game.spawnXY("scout", 60, 58)
game.spawnXY("scout", 28, 29)
game.spawnXY("scout", 61, 24)
game.spawnXY("scout", 60, 58)
game.spawnXY("scout", 28, 29)
game.spawnXY("scout", 61, 24)
game.spawnXY("scout", 60, 58)
game.spawnXY("scout", 28, 29)
game.spawnXY("scout", 61, 24)
game.spawnXY("scout", 60, 58)
game.spawnXY("scout", 28, 29)
game.spawnXY("scout", 61, 24)
game.spawnXY("scout", 60, 58)
game.spawnXY("scout", 28, 29)
game.spawnXY("scout", 61, 24)
game.spawnXY("scout", 60, 58)
game.spawnXY("scout", 28, 29)
game.spawnXY("scout", 61, 24)
game.spawnXY("scout", 60, 58)
game.spawnXY("scout", 28, 29)
game.spawnXY("scout", 61, 24)
game.spawnXY("scout", 60, 58)
game.spawnXY("scout", 28, 29)
game.spawnXY("scout", 61, 24)
ogref = game.spawnXY("ogre-f", 60, 12)
game.spawnXY("soldier", 36, 30)
# Spawn and configure the hero.
hero = game.spawnHeroXY("necromancer", 12, 51)
hero.maxHealth = 666
hero.maxSpeed = 20
hero.attackDamage = 15
game.spawnMaze(1)
# Spawn a munchkin generator.
generator = game.spawnXY("generator", 41, 13)
generator.spawnDelay = 1
generator.spawnType = "munchkin"
generator = game.spawnXY("generator", 41, 13)
generator.spawnDelay = 10
generator.spawnType = "ogre-f"
generator = game.spawnXY("generator", 41, 13)
generator.spawnDelay = 3
generator.spawnType = "skeleton"
generator = game.spawnXY("generator", 41, 13)
generator.spawnDelay = 5
generator.spawnType = "ogre"
generator = game.spawnXY("generator", 41, 13)
generator.spawnDelay = 2
generator.spawnType = "thrower"
# Survive goal.
game.addSurviveGoal()
game.spawnXY("potion-medium", 28, 12)
game.spawnXY("potion-medium", 28, 12)
game.spawnXY("potion-medium", 28, 12)
game.spawnXY("potion-medium", 28, 12)
game.spawnXY("potion-medium", 28, 12)
game.spawnXY("potion-medium", 28, 12)
game.spawnXY("potion-large", 63, 51)
# addManualGoal adds an incomplete goal with a description
# The description will be shown to players.
# NOTE that we save it in a variable!
# Assign the onDefeat handler to the ogres" "defeat"
# NOTE that munchkins don't count toward success!
game.spawnXY("archer", 36, 30)
game.spawnXY("archer", 36, 30)
game.spawnXY("archer", 36, 30)
game.spawnXY("archer", 36, 30)
game.spawnXY("archer", 36, 30)
game.spawnXY("archer", 36, 30)
game.spawnXY("archer", 36, 30)
game.spawnXY("archer", 36, 30)
game.spawnXY("archer", 36, 30)
game.spawnXY("archer", 36, 30)
game.spawnXY("archer", 36, 30)
game.spawnXY("archer", 36, 30)
game.spawnXY("soldier", 36, 30)
game.spawnXY("soldier", 36, 30)
game.spawnXY("soldier", 36, 30)
game.spawnXY("soldier", 36, 30)
game.spawnXY("soldier", 36, 30)
game.spawnXY("soldier", 36, 30)
game.spawnXY("soldier", 36, 30)
game.spawnXY("soldier", 36, 30)
game.spawnXY("soldier", 36, 30)
game.spawnXY("soldier", 36, 30)
game.spawnXY("soldier", 36, 30)
game.spawnXY("soldier", 36, 30)
game.addManualGoal("Kill all enemies")=someGoal
def onDefeat(event):
    unit = event.target
    if unit.type == "ogre":
        # Set the bossGoal.success to True
        hero.say("Boom, baby!!")
        od+=1
    if od <=20:
        someGoal.success=True
    if someGoal.success:
        hero.say("Killed dem ogres!")