An error in the game's code

In the Final Project of game dev 3 the game gives me an error if I try to move
my code :

Spawn a hero with spawnHeroXY()

hero = game.spawnHeroXY(40, 34)
hero.maxHealth = 1
hero.attackDamage = 0

Add at least one goal!

goal = game.addManualGoal(“Vroum Vroum”)
game.addSurviveGoal()
heroSpeed = 6

#en def pour pouvoir faire d’autre partie
def start(heroSpeed) :
hero.pos.x = 28
hero.pos.y = 35
hero.maxSpeed = heroSpeed
#cercle du millieu
game.spawnXY(“fire-trap”, 38, 39)
game.spawnXY(“fire-trap”, 36, 38)
game.spawnXY(“fire-trap”, 34, 37)
game.spawnXY(“fire-trap”, 32, 35)
game.spawnXY(“fire-trap”, 34, 33)
game.spawnXY(“fire-trap”, 36, 32)
game.spawnXY(“fire-trap”, 38, 31)
game.spawnXY(“fire-trap”, 40, 29)
game.spawnXY(“fire-trap”, 42, 31)
game.spawnXY(“fire-trap”, 44, 32)
game.spawnXY(“fire-trap”, 46, 33)
game.spawnXY(“fire-trap”, 48, 35)
game.spawnXY(“fire-trap”, 46, 37)
game.spawnXY(“fire-trap”, 44, 38)
game.spawnXY(“fire-trap”, 42, 39)
game.spawnXY(“fire-trap”, 40, 41)
#cercle exterieur
game.spawnXY(“forest”, 4, 5)

start()

It tells me : Unhandeled error: move's argument pos.y has a problem. Target an {x:number, y: number} position

Can you please format your code using </> so we can help you

1 Like
# Create your own game!

# Spawn a hero with spawnHeroXY()
hero = game.spawnHeroXY(40, 34)
hero.maxHealth = 1
hero.attackDamage = 0
# Add at least one goal!
goal = game.addManualGoal("Vroum Vroum")
game.addSurviveGoal()
heroSpeed = 6

#en def pour pouvoir faire d'autre partie
def start(heroSpeed) :
    hero.pos.x = 28
    hero.pos.y = 35
    hero.maxSpeed = heroSpeed
    #cercle du millieu
    game.spawnXY("fire-trap", 38, 39)
    game.spawnXY("fire-trap", 36, 38)
    game.spawnXY("fire-trap", 34, 37)
    game.spawnXY("fire-trap", 32, 35)
    game.spawnXY("fire-trap", 34, 33)
    game.spawnXY("fire-trap", 36, 32)
    game.spawnXY("fire-trap", 38, 31)
    game.spawnXY("fire-trap", 40, 29)
    game.spawnXY("fire-trap", 42, 31) 
    game.spawnXY("fire-trap", 44, 32)
    game.spawnXY("fire-trap", 46, 33)
    game.spawnXY("fire-trap", 48, 35)
    game.spawnXY("fire-trap", 46, 37)
    game.spawnXY("fire-trap", 44, 38)
    game.spawnXY("fire-trap", 42, 39)
    game.spawnXY("fire-trap", 40, 41)
    #cercle exterieur
    game.spawnXY("forest", 4, 5)
    game.spawnXY("forest", 13, 5)
    game.spawnXY("forest", 22, 5)
    game.spawnXY("forest", 4, 14)
    game.spawnXY("forest", 4, 23)
    game.spawnXY("forest", 4, 32)
    game.spawnXY("forest", 4, 41)
    game.spawnXY("forest", 4, 50)
    game.spawnXY("forest", 4, 59)


start()



I forgot to put the parameter inside the start() command which caused an error

Did you pass the level when you added it?