I’ve been working on 2D terrain generator similar to the terraria. With this tool you can create terraria like game or any other 2D world and you can even have few worlds in one scene with unlimited number of tiles.
Since this system uses marching squares algorithm with even easy to use interface it is not hard to get great looking terrain.
Terrain is infinite.
Here is the preview:
Now you can get it on the assetstore:
As I develop this I’ll be updating this post so stay tuned!
Thank you for your time!
New update.
I’ve been working on a multi threading and along the way I even improved the performance a lot.
There is now even ‘object’ tile which helps to create nice looking trees.
Tile now support events.
Why bother using marching squares? You could do exactly the same thing easier just with rectangular arrays? Marching squares typically have angular edges not right-angles. Do you mean to call it a quadtree?
Well I found somewhere this definition of marching squares: Marching Squares is a family of algorithms for automation that appear in everything from isolating isobars on weather graphs to selecting shape outlines in image editors, and even generating game worlds.
I used marching squares to calculate really fast which tile should be used in a specific condition. ( conditions are already given by the user and the conditions is based on surrounding tiles-squares).
In the terrain below there are only 3 unique tiles( grass , air and dirt). I only set air, dirt or grass in the world. Here is the example without marching squares:
Chunk is made of squares. They have a right-angles.
Now when you define few conditions and use fast marching squares algorithm you get much better result. Shown below.
Condition example;
if this tile is dirt and air is surrounding this tile use a different tile that suits this condition.
With marching squares:
There are many conditions shown in a picture above.
Hope this makes sense!
So, to sum up, I used marching squares to get fast and great looking terrains.
Here is the water that is still WIP. It’s funny how simple it was to implement this in the whole system.
I’m thinking if I should also use marching squares algorithm on water or some different approach to make it look smooth.
//sets all titles in the chunk to tile with array
for (int x = 0; x < World.CHUNK_SIZE; x++)
{
for (int y = 0; y < World.CHUNK_SIZE; y++) {
chunk.SetTileLocal (x, y, 0);
}
}
}
}
Marching squares is sometimes used to render an approximate of blobby objects/metaballs, which happen to work pretty well to represent liquids. However, I would presume recalculating the squares for a lot of cells is hard on performance. Maybe take a look at implementing each water particle/cell as a pre-computed sprite containing an image of the metaball ‘energy field’ which will allow the drops of water to blob together nicely and be very efficient to render - though you’d need a custom shader I think to draw the metafield’s threshold… maybe render water to the display’s alpha channel then grab it?
looks interesting. you should integrate a node based system for the generation of terrains. so that it’s get easy to make lots of biomes and caves with it.