[SOLVED] Help game dev 2 final project python

Welcome to the forum @Lourimax ! :partying_face: This is a friendly place where you can ask help on levels, report bugs, or just chat with other coders! Don’t forget to read the guidelines if you haven’t yet. Have a great time!

Please for the next time, don’t forget to format your code using this button:

As for now, i have done it for you

game.spawnMaze(“forest”, 1)

Create your own game!
hero = game.spawnPlayerXY(“champion”, 38, 10)
hero.maxHealth = 450
hero.maxSpeed = 13
hero.attackDamage = 30

game.addSurviveGoal()
game.addCollectGoal()
game.addDefeatGoal(10)

Spawn objects into the game with spawnXY()
generator = game.spawnXY(“generator”, 60, 60)
generator.spawnType = “munchkin”
generator.spawnDelay = 4
game.spawnXY(“ogre”, 14, 16)
game.spawnXY(“ogre”, 27, 56)
game.spawnXY(“potion-medium”, 57, 44)
game.spawnXY(“potion-medium”, 37, 13)

def onSpawn(event):
     unit = event.target

while true:
     unit.findTheNearestEnemy()
     if enemy:
     unit.attack(enemy)

game.setActionFor(“munchkin”, “spawn”, onSpawn)
game.setActionFor(“ogre”, “spawn”, onSpawn)
bossGoal = game.addManualGoal(“Defeat the boss”)

munchkinsDefeated = 0
ogreDefeated = 0
ui.track(game, defeated)

def onDefeat(event):
     unit = event.target
     if unit.type == “munchkin”:
     munchkinsDefeated = +1
     if unit.type == “ogre”:
     game.setGoalState(bossGoal, True)

game.setActionFor(“ogre”, “spawn”, onDefeat)
game.setActionFor(“munchkin”, “spawn”, ondefeat)