top of page
dkcornett

Generating Level Maps in Godot... A Work In Progress

Overview

For my next project, rather than just iterating on Miasma Theory-- though I do intend to do this-- I thought the next step would be to create a tool that read in a bitmap or other image file, then spat out a platformer level for the game. Creating a tool in Godot is something that looks simple on the surface-- you create an empty project, make a scene that does what you want your tool to do, and export it as a custom node type for you to import into other projects. My original vision for the project boils down to reading in a file-- not hard in most development environments-- putting tiles there from a tileset, and then taking advantage of Godot's autotile system, which lets a developer draw tiles onto the scene and determines what tile from the set to place based on how many tiles are in the space around it.


This was a lot of steps where I assumed something "would not be complicated".


I also determined that I would not look at how other developers created entire level editing tools for their games, because I "wanted the work to be my own". I felt that too much of my codebase for Miasma Theory was based on tutorials I had read or watched and I wanted to figure things out more on my own now that I had some baseline experience with the engine. Sticking to this ended up making the project a great deal more complicated. It also goes against the grain of what open-source development is. Developers building off of each other is what makes the open source community powerful.


Step 1: Autotile

Using the an extended version of the free to use tileset by Kenney that I used in my original project, I set out to set up autotiling for a platforming game. Wrapping my head around this took far too much time. Autotile, as I said, determines what tile to place based on how many tiles are on the grid space around it and where they are.





This means that allowing for diagonals in a grid-based autotile is a fool's errand. I spent a week trying to figure out what I was doing wrong! I could get peaks when drawing tiles, but the tiles underneath would be the default tile from the set, rather than the "underneath a corner" tile from the set. I realized that the tileset I was using was not ideal for what I wanted to do, but I thought if I kept trying different layouts for my autotile, I would figure out how to make it work.








On further research, though, I found out that using a grid-based autotile to detect diagonals is not recommended due to the type of complication I was having. In the end, I defaulted to allowing for corners on my autotile, but not using diagonals, since this was not my main goal for the custom node. With that autotile in place, I added colliders to each tile like I did setting up the non-autotile tileset I used for the base Miasma Theory. From there, I saved the tileset as a resource so I could feed it into another tilemap for the next step.




Step 2: Generating Tiles From Elsewhere In Script


With a tileset and its autotile bitmap set up, the next thing I needed to do was have another tilemap node read in the first tilemap and spit out tiles in the same location. This was meant to be an intermediary step before fully reading in bitmaps to generate new tilemaps.


... I could not get the new tilemap to generate tiles. I did cave in and look at some tutorials and Godot forum posts on this issue. There were people who were able to generate tiles (or replace them) using their index value from the tileset. But I could not get them to show up in the new tilemap. Perhaps I was reading in the values from the old tilemap incorrectly. Perhaps I have some other variable being used incorrectly on the new tilemap.





To Be Continued...


This project exists in the "leveltool" branch of the Miasma Theory repository. I intend to continue developing it, but I do not consider this project finished at the time of this posting.

10 views

Recent Posts

See All

Comments


bottom of page