Small scale road generation

Godot Version

4.3

Question

Alright this might be a bit of an ask but I’m attempting to procedurally generate small maps for the game I’m working on. I’ve already figured out how to generate terrain on a tile map.

This is sort of what I’m going for with my maps:

New Piskel-1.png_scaled_10x_pngcrushed

Right now what I’m asking is for any ideas or just algorithms to check out for generating grid based road across my map. Just asking around if there’s any techniques around for something like this maybe?

1 Like

I dont quite understand your approach.
It’s easy to have a png and then loop through the pixels and then do something with them.

var map = Image.load_from_file("PATH/TO/PNG")
var map_size = map.get_size()
    for x in map_size .x:
        for y in map_size .y:
            var pixel : Color = map.get_pixel(x,y)
            # Check if Color is white, grey or black
            # Do what you want with this information

There are many ways to generate a map out of this.
The easiest way is to have a tilemap that has 3 different tiles that represent the generated map on your png but just scaled up by quite a bit.
Or you create entire landmasses, create a new class called “WorldTile” and place those in a grid.
You can also think about dependencies. For example, if you have a road but 3 neighbors are not road, which means the current tile is a dead end which could be a unique tile.

I have no information about your game, is it a 2d topdown strategy game, or is it a 3d world with altitude and hills for some battle royale game, or is it a dungeon crawler where you generate the tiles that can be destroyed with some hidden rooms. Regardless of it all, i hope my response is of help to you. Good luck

If it stays 2d, maybe working with a tilemap is the way to go. I believe it is also possible to precreate patterns and apply those by code. (for situations for diagonal roads, dead ends, road branches, …)