Developping an Automap
What and why⌗
Back from my long trip to Japan, I started back game dev, with the feature that was most requested during play tests: an Automap.
Old DRPG and gamebooks didn’t have a map, you are supposed to take graph paper and map out the dungeon as you go. Some DRPGs still require you to draw a map, sometimes, even in the game, like Etrian Odyssey. However, most games nowadays have an Automap which makes games much more accessible to the common mortal.
This article is not a tutorial but more a log of my decision-making, that I am writing for myself.
Making the minimap⌗
First, I already have a strong foundation, since I was able to generate a 3D map from a JSON map generated with Tiles. I just needed to repeat the process, for 2D.
Basics⌗
- Generate a map of 1 layer of the dungeon with bogus data. Having bogus data allows me to test and ensure the code does not rely too much on the general codebase/game state.
- Make the script a @tool in Godot to be able to launch generation in the editor. This speeds up the process immensely.
- Add a hint for the player’s position. Rotate this hint depending on player rotation
Once I had this, there was a major issue: the whole map was revealed, and there would be no charting, no exploration if you could just go where you needed.
Hide it⌗
- Add a “visited” property on every Cell of the dungeon.
- Every time the player steps on a cell, it is visited.
- Add a condition to draw a tile on the map, if the cell is visited.
- Save visited cells on the Singleton that holds player data.
- Save this when you save the game
Make it a minimap⌗
- Add a viewport to Godot and the map to itch
- Add a camera on the player hint so the view is always centered
Making the map menu⌗
My game is in 3D so it would be nice for the player to be able to go around the floors to see how they should traverse the dungeon. For this, I need people to interact with the map. I decided to make a mpa menu, like many other games.
Basics⌗
- Reuse the map from before, without the camera.
- Made the map pop on the screen with the button “m”.
- Being able to change the layer displayed, with keyboard press.
- Add an indicator of which layer we are.
- Add 2 animated buttons that can be clicked to change the layer. They also are animated when you use the keyboard for feedback.
Now you can fairly well see the dungeon. But I wanted people to be able to do more, tell which case they are in, and be able to place notes. This is a bit bonus, but there was still time on my time budget.
Building up Note-taking⌗
- Add a cursor, and make it move on the grid, with a mouse or keyboard.
- Display a hint of where the cursor is.
- Save a position in memory, on button press.
- Save a position and text, on button press.
- Save a position and text coming from custom input on button press.
- Display these notes on the screen.
- Allow to remove those inputs.
- Allow to edit those inputs (actually, I just removed and recreated one).
Weirdly, I was working fast on a single layer, but up until now, the location of the cursor and note wouldn’t take into account the layer, so I had to refactor a bit for this.
- Add Z to location and notes.
- When the layer is changed, remove displayed notes to only display those from current layers.
- Add an Icon for notes
- Add highlight when you go over a note
Now it’s nearly finished. If you close the map, you lose all your precious notes. So we have to remedy this:
- Create a variable on the Singleton that holds the data related to the current state of the game.
- Save the notes by position and level there, when you close the map
- When you open the map, try to load the notes present on this Singleton.
- When you save your game, the notes are written as well. When you load your game, this variable is loaded as well.
And now I have a fully featured map for my game.
There is still work needed on it:
- Add more contrast to be able to see clearly, everything there is to see.
- Add control hints so the player knows how to interact with the map.
- Add a shortcut to directly take a note on the cell you are standing.
- Test it with real players (!!!).
- Adjust the size of the map or implement a zoom if it becomes too big (not a problem at the moment).