CodeCombat | Paradigm Shift[SOLVED]

Hello! For this level, the goals keep saying “incomplete,” but I don’t know what’s wrong!

Here’s my code:

# This level is a platformer game with adjustable gravity.
# Read to see how the program works.
# Follow directions to customize player controls with events.
# Then collect the coins to win the game.

# This code sets up the map with some platforms:
game.spawnFloor("mountain")
game.spawnTopBorder("desert")
game.spawnXY("forest-platform", 10, 10)
game.spawnXY("forest-platform", 18, 10)
game.spawnXY("forest-platform", 36, 20)
game.spawnXY("forest-platform", 44, 20)
game.spawnXY("forest-platform", 76, 10)
game.spawnXY("forest-platform", 20, 40)
game.spawnXY("forest-platform", 28, 40)

# This spawns some gems to collect.
# You can add more if you want to:
game.spawnXY("gold-coin", 20, 48)
game.spawnXY("gold-coin", 60, 40)
game.spawnXY("gold-coin", 75, 20)
game.spawnXY("gold-coin", 5, 40)

# You can decide the strength of the gravity.
# This sets it to 0 left/right and 30 down:
game.setGravity(0, 30)
# This makes the platforms ignore gravity,
# so they don’t fall down:
game.setPropertyFor("forest-platform", "ignoreGravity", True)

# Now we spawn the player and set her speed:
game.spawnXY("raider", 10, 18)
game.setPropertyFor("raider", "speed", 20)

# Time to try new events!
# You’ve used "click" events before.
# Now, you can also use keyboard events. 
# This makes the "raider" jump when spacebar is pressed:
game.onInput("space", handler.jump(35, "raider"))
# This makes the "raider" move right when "d" is pressed:
game.onInput("d", handler.moveRight("raider"))

# Your turn:
# Make it so the "raider" moves LEFT when "a" is pressed:
game.onInput("a", handler.moveLeft("raider"))

# Let's learn one more.
# handler.stop() stops movement.
# The "collide" event happens when two things touch.
# Make it so "raider" will stop() when a "collide" occurs:
game.onInput("collide", handler.stop("raider"))

# We need one more handler.
# handler.defeat() causes a unit to be defeated.
# The "exit" event happens when a unit exits the map.
# Make it so the "raider" is defeated if it exits the screen:
game.onInput("exit", handler.defeat("raider"))

# Finally, let’s set goals and write directions.
# The raider must survive and collect all coins:
game.addSurviveGoal("raider");
game.addCollectGoal();
# These lines tell the player what to do:
ui.setText("directions", "Collect all coins");
ui.setText("directions", "Controls:");
ui.setText("directions", "'A' - move left");
ui.setText("directions", "'D' - move right");
ui.setText("directions", "Space - jump");

Help, please!

Do your goals look like this?
image

No, it looks like this:

Screenshot 2021-06-08 9.40.16 AM

Again, here is my code:

# This level is a platformer game with adjustable gravity.
# Read to see how the program works.
# Follow directions to customize player controls with events.
# Then collect the coins to win the game.

# This code sets up the map with some platforms:
game.spawnFloor("mountain")
game.spawnTopBorder("desert")
game.spawnXY("forest-platform", 10, 10)
game.spawnXY("forest-platform", 18, 10)
game.spawnXY("forest-platform", 36, 20)
game.spawnXY("forest-platform", 44, 20)
game.spawnXY("forest-platform", 76, 10)
game.spawnXY("forest-platform", 20, 40)
game.spawnXY("forest-platform", 28, 40)

# This spawns some gems to collect.
# You can add more if you want to:
game.spawnXY("gold-coin", 20, 48)
game.spawnXY("gold-coin", 60, 40)
game.spawnXY("gold-coin", 75, 20)
game.spawnXY("gold-coin", 5, 40)

# You can decide the strength of the gravity.
# This sets it to 0 left/right and 30 down:
game.setGravity(0, 30)
# This makes the platforms ignore gravity,
# so they don’t fall down:
game.setPropertyFor("forest-platform", "ignoreGravity", True)

# Now we spawn the player and set her speed:
game.spawnXY("raider", 10, 18)
game.setPropertyFor("raider", "speed", 20)

# Time to try new events!
# You’ve used "click" events before.
# Now, you can also use keyboard events. 
# This makes the "raider" jump when spacebar is pressed:
game.onInput("space", handler.jump(35, "raider"))
# This makes the "raider" move right when "d" is pressed:
game.onInput("d", handler.moveRight("raider"))

# Your turn:
# Make it so the "raider" moves LEFT when "a" is pressed:
game.onInput("a", handler.moveLeft("raider"))

# Let's learn one more.
# handler.stop() stops movement.
# The "collide" event happens when two things touch.
# Make it so "raider" will stop() when a "collide" occurs:
game.onInput("collide", handler.stop("raider"))

# We need one more handler.
# handler.defeat() causes a unit to be defeated.
# The "exit" event happens when a unit exits the map.
# Make it so the "raider" is defeated if it exits the screen:
game.onInput("exit", handler.defeat("raider"))

# Finally, let’s set goals and write directions.
# The raider must survive and collect all coins:
game.addSurviveGoal("raider");
game.addCollectGoal();
# These lines tell the player what to do:
ui.setText("directions", "Collect all coins");
ui.setText("directions", "Controls:");
ui.setText("directions", "'A' - move left");
ui.setText("directions", "'D' - move right");
ui.setText("directions", "Space - jump");

This part is incorrect. It should be:

game.setActionFor("raider", "collide", handler.stop())
# We need one more handler.
# handler.defeat() causes a unit to be defeated.
# The "exit" event happens when a unit exits the map.
# Make it so the "raider" is defeated if it exits the screen:
game.setActionFor("raider", "exit", handler.defeat())

It should work then. You want to set an action for when the raider exits the screen. It should not be an input.

1 Like

Thank you! It worked!

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.