Hello. I'm trying to study Godot while I'm watching different lessons and in all the cards are created using square titles. Is it possible in the program to create, for example, a script for generating a map not by squares? For example, if you open a Google map of any country, then the cities there are in the form of uneven gray figures on a green field. Here, each gray piece is like one district (piece of a city or village) - a separate sprite ... and is it possible to write a script in such a way that the program randomly places these figures, forming different cities and villages? The green part of the map will be used as a background. Can roads be randomly generated like that? So that each new game gives the player a new card. What lessons should I pay attention to in this case? At the same time, I want to make the map interactive, where some sprites or points on a sprite are places with some kind of event ...


Ask yourself "Am I in over my head?"

If yes,
try stripping the idea down. Look at generating a simpler map using a Dictionary that holds data on each town. Randomly pick a spot for town #1 or hard code it, and from there, you could use the position and size of town#1 to generate the next town, and the next one, and the next one. Use the rando math outputs to put grey sprites on a green background.
Dictionaries, 2D vector math, and loops will all be pretty close friends of yours by the time you're thinking about roads again.

If no,
you're smarter than me.

Don't underestimate vomiting logic onto a piece of paper or your IDE.

Hmmm...
I wouldn't know how to do it most efficiently, this is just a thought:

I would suggest using a noise map and clamp the values for some flat regions for the cities.
Take the outer most values and get rid of like 90% of them at random.
The rest you should use as points to generate polygons.

Roads should be possible with a maze generator, but use the values to generate polygons.
I would suggest looking into Polygon2D, noise generation and maze generations.

Hmm... as a person with a rather primitive understanding of coding, I'm currently trying to make sense of all the written advice (and I hope that the translator translated everything correctly for me)... I understand correctly that writing a script for an entire map and roads separately - is it too complicated and doesn't make sense? I will try to paint a little differently - as an artist (who does not know how to program, but is only learning) I just want to find out for myself how exactly I should draw a map.
Example:

1) If the card should be only titles - as an option, you can create several dozens of such titles and combine them in different ways (that is, the card will not be made of 40 or 200 different pieces, but only selected from 10-12 ready-made templates... )... this will be a pseudo-simulation of the card variety, but much simpler...

2) In some lessons, I saw how trees were placed on the map with the help of a script. The second option follows from this - can I scatter these specks on the map according to the principle of generating trees?

P.S. It's not that I want to somehow jump above my head and immediately create something incredible (although maybe that's exactly what I'm doing)... I just know what the game will be about and in general I try to understand for myself how I like it without rejecting the idea and plot create (that's why no 3d, realistic graphics and the like - because I don't know how to do it)... I still don't quite understand how to make programming easier or break it into small pieces, so my thoughts can be chaotic. Please don't be offended by this))

I assume you meant tiles not titles. In which case, depends on the scale. Generating the terrain if of large enough scale you want 'tiles' for optimization purposes. Rather the term to look up is chunks. That doesn't necessarily mean you can't do advanced things that wont display the underlying chunky nature of the system. Your generator just needs to be capable of comparing for features between neighboring chunks.

That's right tiles, not headers. I suppose that I could have written Title (which the translator automatically translated into English letters and the title came out)... but I should have used the word Tile. I apologize for the misunderstanding.

Here is the last phrase - Your generator should simply be able to compare characteristics between neighboring blocks - interested.
And with the help of a script, it is possible to configure so that the program recognizes, for example, the color on the tile? To connect green to green, white to white, and so on... Then, having, for example, a row of tiles with roads drawn on them - highway and rural - the program could connect the roads correctly... For example, the tiles are drawn unevenly, but this is just an example for recording.

Voronoi's method looks very interesting. By the way, the article also has a direct link to a book with a detailed analysis of the code. I will definitely look into this method - it might come in handy.

Kim_Laone changed the title to Generating a map not by tiles - is it possible? .