Updating the Maze-Designer

Starting with the pac-man maze designer, i added new buttons and updated the existing code to use hero, monsters and treasure.

New Buttons Added, Doors, Keys, Food & Drink ; Hero and Monsters changed

Creating the code for the button calls on the function values supplied in the button i.e.

Set tool value based on the button
    ;; Green Door
    if tool = "Draw Green Door"
    [ draw-boundary green ]
    ;; Red Door
    if tool = "Draw Red Door"
    [ draw-boundary red ]
    if tool = "Draw Yellow Door"
    [ draw-boundary yellow ]

Which when applied creates the required doors

Different coloured doors which will only be accessible when holding the correct keys

The next step was to create the key. As there was no key graphic, the netlogo shap editor was used to create one.

green key creation

Then the code to support the creation and placement

breed       [ green-keys green-key ]
    create-green-keys 1
      set color green
      set shape "green key"
      setxy 10 10
to place-greenkey
  ifelse [pcolor] of patch round mouse-xcor mouse-ycor != black
  [ user-message "You must place the key on a corridor space, not a wall or a gate." ]
    ask green-keys
    [ setxy (round mouse-xcor) (round mouse-ycor) ]

When setting up the new level, the green key is now available to place.

doors and keys created

In the actual game i will now be able to have a register for ‘keys’ and when the hero encounters the key, take it and be able to pass the green door.

Leave a Reply

Your email address will not be published. Required fields are marked *