So I’m using the school vers. of CodeCombat. I’m on Game Development 2, the final level. In this level, you have to make your own game. And I want to add a goal to my game where you have to destroy all of the generators. But I don’t know how to do that. So basically my question is how do I check if an object is destroyed. My code for the level is this so far:
# Create your own game!
# Spawn a player with spawnPlayerXY()
player = game.spawnPlayerXY("samurai", 7, 9)
player.maxSpeed = 20
player.maxHealth = 1
# Add at least one goal!
game.addDefeatGoal(4)
generatorGoal = game.addManualGoal("Destroy all generators")
# Spawn objects into the game with spawnXY()
game.spawnXY("forest", 8, 21)
game.spawnXY("forest", 16, 21)
game.spawnXY("forest", 24, 21)
generator1 = game.spawnXY("generator", 71, 60)
generator1.spawnType = "ogre-f"
generator2 = game.spawnXY("generator", 71, 6)
generator2.spawnType = "ogre"
game.spawnXY("potion-small", 21, 11)
trap1 = game.spawnXY("fire-spewer", 8, 17)
trap2 = game.spawnXY("fire-spewer", 16, 17)
trap1.direction = "vertical"
trap2.direction = "vertical"
I’m not a super nerd about coding, a noob at it myself.
But welcome to the community @tazrXx! You’ll find some interestingly weird people here. (Like me)
Welcome to the forum! This is a family-friendly place where coders can share bugs, ask for help on any CodeCombat level (don’t forget to post your code correctly), or just hang out with other coders. But before you proceed, please check out our guidelines: this topic.
Have a great time!
I’m not a sub so I am unable to access this level and help you, however, maybe @Aya will be able to.
So this goal over here is only accomplished when you kill 4 ogres. If you want the goal to be accomplished when all the enemies are killed, you can just remove the number.