I finished the stage: “Adventure Time” but it seems like Im confused by how the spawn and game.time in this stage works. There is created a variable called “SpawnTime = 0” which makes the variable equal 0. It is then used in the if statement in the while true loop:
"if game.time > spawnTime:
game.spawnXY(“munchkin”, 60, 35).
So the game spawns a munchkin if game.time has been running longer than the spawnTime variable which is set to 0 which will happen after 1 second, which make a lot of sense. And then just keep chain spawning the munchkins.
But further down in the if statement there is another variable called the same name: spawnTime = game.time + 2.
I understand the concept that every 2 seconds of game time it should spawn another munchkin.
But I don’t understand how the two variables can operate together and not cause interference ? The variable (outside the while true loop) equals 0 and the other variable equals game.time + 2 (inside the while true loop)