Need help- Game Development Level 2

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!

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

Thank you! I will try it…



# 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!

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

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

// 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
// Use the variable to configure the generator below.
var generator = game.spawnXY(“generator”, 60, 40);

// Set the generator’s spawnType to “munchkin”
var vargeneratorspawnType = “munchkin”;

// Use spawnPlayerXY to spawn a hero for the player.
var player = game.spawnPlayerXY(“knight”, 15, 15);

// Set the player’s maxHealth to at least 100
player.maxHealth = 100;

// Set the player’s attackDamage to at least 10
player.attackDamage = 10;

// Play the game!

Not working! Need help!

Please learn to post your code correctly. The way it is now, we can’t see the structure. Help us help you. It’s very easy to do and just takes a tiny bit of effort. Please read this topic and format your code again correctly

You can tap on the knight in spawnables look at the default code then use but put what you want in