Need help- Game Development Level 2


#1

We are new to Code Combat and trying to understand coding. I (mom) need help to show my son (age 14) how to get past this level he is on. He has some beginning knowledge of code and I have little to none so it is tough getting through this. I hate that we bought this and even after contacting Code Combat and getting some hints in a reply from the CEO, we still can’t get past this. Honestly, it all give me a headache, but I am determined to press through and not get too frustrated!

He is on Game Development- part 16 called Time to Live. The code he tried and then edited with hints from the CEO are… (what is the best way to copy and paste the code here for people to see it?- I think it would help if the line numbers were there, but I don’t know how to copy and paste that)

Pass an argument to addSurviveGoal() to specify a time.

This means the player must survive for 20 seconds.

game.addSurviveGoal(20)

Spawn a generator with spawnXY

Remember to assign the spawned generator to a variable!

Use the variable to configure the generator below.

generator.spawnType=“munchkin”

Set the generator’s spawnType to “munchkin”

mySpawn = game.spawnXY(“generator”, 36, 30)
generatospawnType=“munchkin”

Use spawnHeroXY to spawn a hero for the player.

Remember to assign the spawned hero to a variable!

hero = game.spawnHeroXY(55, 16)

Set the hero’s maxHealth to 100

hero.maxHealth=100

Set the to 10

hero.attackDamage=10

Play the game!


#2

I can’t help with code but to paste code here do the following.

Go to FAQ and look for where it talks about triple brackets


#3

Thank you! I will try it…


#4


# This means the player must survive for 20 seconds.
game.addSurviveGoal(20)

# Spawn a generator with spawnXY
# Remember to assign the spawned generator to a variable!
# Use the variable to configure the generator below.
# generator.spawnType="munchkin"
# Set the generator's spawnType to "munchkin"
mySpawn = game.spawnXY("generator", 36, 30)
generatospawnType="munchkin"
# Use spawnHeroXY to spawn a hero for the player.
# Remember to assign the spawned hero to a variable!
hero = game.spawnHeroXY(55, 16)
# Set the hero's maxHealth to 100
hero.maxHealth=100 
# Set the  to 10
hero.attackDamage=10

# Play the game!

#5

I haven’t done game dev yet but this appears to be a problem.


#6

There is more to it…

mySpawn = game.spawnXY(“generator”, 36, 30)

Think of that line of code in reverse, so you will be naming the spawned generator
what it (equals)

so you have to set
generatospawnType="munchkin"
to
mySpawn.spawnType=“munchkin”

if you play back through a few of the levels in front and really read the code you should understand why,
ie. level 15. behavior driven development…

skeleton1 = game.spawnXY(“skeleton”, 60, 50)
skeleton2 = game.spawnXY(“skeleton”, 60, 30)
skeleton3 = game.spawnXY(“skeleton”, 60, 10)

skeleton1.behavior = "Scampers"
skeleton2.behavior = “Scampers”
– Assign “Scampers” to skeleton3.behavior
skeleton3.behavior = “Scampers”

– used for the comment