[SOLVED] Enemies not spawning on Game Dev 2 Final Project (Python)

On my code the enemies are not spawning in the level

game.spawnMaze("forest", 97)
player = game.spawnPlayerXY("knight", 36, 28)
player.maxHealth = 1
player.attackDamage = 0
game.addSurviveGoal(50)
game.addManualGoal("Dont get touched by enemies !")
# Spawn objects into the game with spawnXY()
waveCooldown = 5
waveSize = 5
waveTime = 3
ui.track(game, "time")
def spawnEnemies(offset) :
    thrower = game.spawnXY("thrower", 12 + offset, 12)
    munchkin = game.spawnXY("munchkin", 12 + offset + 5, 12)
    scout = game.spawnXY("scout", 12 + offset + 7, 12)
def wave() :
    
    while game.time > waveTime :
        offset = game.randomInteger(0, 30)
        spawnEnemies()
        waveTime = game.time + waveCooldown
archer = game.spawnXY("archer", 41, 30)
archer.maxSpeed = 0
while True :
    wave()

You forgot to put in a parameter, you defined it, but forgot to use it

I corrected the problem but the enemies are still not spawning

Can you repost your new code please?

game.spawnMaze("forest", 97)
player = game.spawnPlayerXY("knight", 36, 28)
player.maxHealth = 1
player.attackDamage = 0
game.addSurviveGoal(50)
game.addManualGoal("Dont get touched by enemies !")
# Spawn objects into the game with spawnXY()
waveCooldown = 5
waveSize = 5
waveTime = 3
ui.track(game, "time")
def spawnEnemies(offset) :
    thrower = game.spawnXY("thrower", 12 + offset, 12)
    munchkin = game.spawnXY("munchkin", 12 + offset + 5, 12)
    scout = game.spawnXY("scout", 12 + offset + 7, 12)
def wave() :
    
    while game.time > waveTime :
        offset = game.randomInteger(0, 30)
        spawnEnemies(offset)
        waveTime = game.time + waveCooldown
archer = game.spawnXY("archer", 41, 30)
archer.maxSpeed = 0
while True :
    wave()

1 Like

Try replacing the above with this: waveTime += 5

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.