Play Home Contribute Github Join Us! Discourse Staff Members Github Contribution Guides Team

[Guide] Creating a Level With a Goal Point

Intro

Welcome! Today, we’ll create a new level using CoCo’s level editor that involves character movement, fighting, and some decorations!

Steps

  1. Start by creating a new level in the level editor. Feel free to name it anything you want. (I named it Treasures of Kithgard)
  2. Create an 80 by 64 dungeon floor. Like this:
  3. Add a Hero Placeholder Thang anywhere in the map(We’ll change the position later.
  4. Place dungeon walls around the floor(2 layers)
    48%20PM
  5. Start creating your maze. I used movement stones, dungeon walls, and dungeon stairs.
    Make sure to check that the spacing between each movement stone is 12 meters(Or 3 shifts with the stone). This is because we are making so simple boots are used. Here’s a screenshot of mine:
    27%20PM
  6. As you can see in the above image, there are some cave-ins. These allow ogres to hide and wait for the hero to approach.
  7. Add a munchkin to each “booth”(Cave-in) in your level. Then set their vision.sees() distance to 10m.
  8. Add a gem in front of each ogre munchkin
  9. Add a goal trigger at the end of the maze
  10. Go to the settings tab of the level and create the following:
  11. Add a referee to your level. (It is recommended you place it where you can see it. Don’t worry, it’s invisible in play mode)
    46%20PM
  12. Double Click the referee
  13. Go to misc.referee and click the plus button. In the dropdown menu, select extra code.
  14. Referee’s code language is Coffeescript, but the structure is similar to unity’s C# script. Type in the following code in the referee extracode: (You might need to change the number 20 to something else)
{
  setUpLevel: ->
    @inventory = @world.getSystem("Inventory")
    @inventory.teamGold.humans.income = 0
    @inventory.teamGold.humans.earned = 0
    @inventory.teamGold.humans.gold = 0
  #onFirstFrame: ->
    
  #chooseAction: ->
  
  checkVictory: ->
    if @inventory.teamGold.humans.collected==20 # Change this to GemCount*5
      @world.setGoalState("collect-gems", "success")
    if @inventory.teamGold.humans.collected<20 # Change this to GemCount*5
      @world.setGoalState("collect-gems", "failure")
    
    
}
  1. Try your level, it should work as expected! Here’s mine: https://direct.codecombat.com/editor/level/treasures-of-kithgard

Congrats! You've finished creating a simple level with a goal point!

Things we covered:

  • Maze creation and decoration
  • Gem inventory system
  • Basic referee coding
  • Editing components

As an extra challenge, try adding doors, and maybe documentation! Good luck!

1 Like