Compass(es)

Due to the size of the mazes it is pretty hard for the player to find the exit in the allotted amount of time. It feels like it just comes down to luck, as to whether or not the player happens to stumble upon the exit. To remedy this, I decided to add a compass to the players UI that points them towards the exit of the current maze. Rather than dive into the world of 3D models I decided to to simply manipulate a 2D image to produce an array of images that enable the compass to point in a full 360 degrees.

An array of a simple compass sprite showing the various directions that the triangle in the center of the sprite can be oriented.

However, perhaps due to the relatively large number of sprites that I created, the compass spins WILDLY if the yaw of the player is factored into its position. After a few hours of troubleshooting, Okham’s Razor got the best of me and I decided to simply have it point towards the exit based solely on the player’s current position in the maze and the exit’s position in the maze.

This does offer a unique opportunity to add more progression to the game. Once I can properly implement the mouse input, I can make an upgraded compass that the player can some how obtain that enables them to navigate the maze more efficiently by incorporating the player’s current view angle into the compass’s orientation.

Ideally I would like to eventually have the player choose one of three random upgrades every few levels. These upgrades could include things like increased time gained per-level, increased speed, or other items that shake up the gameplay in some way. As I continue to refine the mechanics of the game, it is important to keep the player experience in mind; no one wants to run through the same maze for hours. Along these same lines, I would like to eventually add some kind of visual variation to the maze itself as the player completes more and more mazes in a single life.

After additional experimentation, I discovered that the answer to properly implementing yaw tracking was to mirror the same trigonometric calculations performed by the player movement functions. The compass needle now properly points in the correct direction relative to both the player’s position and their viewing angle, using the following approach:

  1. Calculate the direction vector from player to exit
  2. Get the forward vector based on the player’s yaw (using sine and cosine)
  3. Get the right vector perpendicular to the forward vector
  4. Project the exit direction onto these vectors to get the relative angle

The result is a compass that now smoothly indicates the exit’s position relative to which way the player is facing, making navigation through the maze far more intuitive.

With yaw tracking, solving the mazes is MUCH easier since the player no longer needs to mentally translate between absolute directions and their current orientation. As a result, I’ve created two distinct compass models: a basic version that only shows absolute direction (regardless of player orientation), and a premium “gold compass” that incorporates the player’s current viewing angle.

Side-by-side comparison of the regular compass (left) and gold compass (right)

This provides a perfect opportunity for an in-game upgrade that can be earned as the player progresses. I envision an achievement system where players can unlock the gold compass after completing a certain number of mazes, or by finding a special pickup in a particularly challenging level. The enhanced compass would then become a permanent upgrade, providing a tangible reward for player progression while maintaining the game’s increasing difficulty curve through other mechanics like maze complexity and time constraints.