How to make a "compass"-system in your game

Hello comrads! I want to talk you about simple symple “compass”-system, which you can use in you own game.

  1. First of all you must create variables:

*create n_s “entrance”
*create v_n_s 0
*create e_w “entrance”
*create v_e_w 0

Clarification: n_s - north_south and e_w - east_west. v - visited.

  1. Line, where you give the player information about where is he located now.

Compass: the number of transitions from the entrance to the cave (south-west: {n_s}; east-west: {e_w}).

  1. Code in button, if player make step to the north direction.

#Go to the north.
*set v_n_s +1
*if v_n_s > 0
*set n_s “{v_n_s} transitions to north" *if v_n_s = 0 *set n_s "entrance" *if v_n_s < 0 *set v_n_s (v_n_s -(v_n_s * 2)) *set n_s "{v_n_s} transitions to south”
*set v_n_s (v_n_s -(v_n_s * 2))

If player walk to the south just replace set v_n_s +1 with set v_n_s -1

Code in button, if player make step to the east direction.

#Go to the east.
*set v_e_w +1
*if v_e_w > 0
*set e_w “{v_e_w} transitions to east" *if v_e_w = 0 *set e_w "entrance" *if v_e_w < 0 *set v_e_w (v_e_w -(v_e_w * 2)) *set e_w "{v_e_w} transitions to west”
*set v_e_w (v_e_w -(v_e_w * 2))

If player walk to the west just replace set v_e_w +1 with set v_e_w -1

This method is very stupid and simple, but if you want to add to you game cave or labirinth, like in old-style game-book, it may be usefull ))))

*Edit made it home and going to redo this

I am not a master coder but I would approach it a little simpler.

*create north false
*create northwest false
*create west false
*create southwest false
*create south false
*create southeast false
*create east false
*create northeast

There are three doors you can choose to go through
*choice
 #East
  *comment just copy and paste the following
  *set north false
  *set northwest false
  *set west false
  *set southwest false
  *set south false
  *set southeast false
  *set east false
  *set northeast false
  *comment set direction
  *set east true
 #West
  *comment just copy and paste the following
  *set north false
  *set northwest false
  *set west false
  *set southwest false
  *set south false
  *set southeast false
  *set east false
  *set northeast false
  *comment set direction
  *set west true
 #North
  *comment just copy and paste the following
  *set north false
  *set northwest false
  *set west false
  *set southwest false
  *set south false
  *set southeast false
  *set east false
  *set northeast false
  *comment set direction
  *set north true

Looking at your compass
*choice
 #Compass
  *gosub compass

*label compass
*if (north)
 You are heading North
 *return
*if (northwest)
 You are heading Northwest
 *return
*if (west)
 Your are heading west
 *return
*if (southwest)
 You are heading Southwest
 *return
*if (south)
 You are heading south
 *return
*if (southeast)
 You are heading Southeast
 *return
*if (east)
 You are heading East
 *return
*if (northeast)
 You are heading Northeast
 *return

1 Like

You can do it even easier than that by using a gosub to set them all to false before the choice then have the choice change the relevant direction to true. It’d save having to have a *set [direction ] false for each direction.

1 Like