# Unity Procedural generation for 2d tile game

This topic is 1110 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi everyone, i just joined you lovely community.

I need some theoretical help. I'm developing 2d tiled puzzle game, inspired by Minecraft mechanics a bit. Game is about digging down the procedural generated mine, collecting ores, avoiding monsters.

What i have done by now:

[attachment=24773:1.png]

Level is just randomly generated of 3 different terrain types.

What i need help with:

[attachment=24774:2.png]

I'd like to find a way to randomly select groups of tiles, which i will generate as rock type terrain, resembling rocks laying under ground. It should have random shapes and size, but close to circle, and have some distance between zones.

Some my thoughts by far:

[attachment=24775:3.png]

1) Find initial cell

2) For every neighbor of new cell, select this cell with chance depending on distance of this cell from initial cell

3) Recurse for every selected cell

I'd love to hear your ideas about zone selection and its placement around level.

##### Share on other sites

Here's a very simple approach:

Use perlin noise (always a good procedural content generation startpoint ) to generate the map and assign value ranges to certain materials, something like this

0.0 - 0.7 earth

0.7 - 0.95 rock

0.95-1.0 gems

##### Share on other sites

Try to research "Cellular Automata"

##### Share on other sites

Hi,

I've made experiments on a similar problem a while ago (biome placement on a procedural map). One alternative way for solving that type of problems could be to use a constraint solver like Google OR Tools. With OR Tools, you have to express the constraints of your system :

- My domain is a X*Y grid

- I want at most 25% of rock blocks

- Near a rock block there's 75% of chance to have a sand block

etc..

Set the seed, call Solve(), and you get a solution.

The main difficulty is to express the constraints, but I think it could be a very interesting approach, and can give a very good control of the generation.

Anyway, our actual generator is based on Perlin (GPU generation), and it works fine... Just an idea ;)

Edited by DTR666

##### Share on other sites

I'm a bit late on this post, but I'd suggest avoiding Perlin noise and instead using something I like to call OpenSimplex noise: https://gist.github.com/KdotJPG/b1270127455a94ac5d19 (An algorithm I designed for a currently-WIP game because I wanted to avoid both the artifacts of Perlin noise and the patent of 3D Simplex noise)

Perlin noise is an older algorithm that tends to exhibit significant grid artifacts by way of lining all of its features up with the cardinal axes and main diagonals. OpenSimplex noise should provide you with a bit more variety in the directions that your terrain features go. Perlin noise can certainly do some cool stuff, but what you can do with Perlin noise you can probably do better with a more visually-isotropic noise like OpenSimplex.

Perlin (top) vs OpenSimplex (bottom), 2D slices of 3D:

• First is noise(x, y, 0) grayscale
• Next is noise(x, y, 0) > 0 ? white : black
• Next is |noise(x, y, 0)| < 0.1 ? black : white
• Last is noise(x, y, 0.5) grayscale to illustrate that Perlin noise looks "weird" in non-integer slices
Edited by KdotJPG

##### Share on other sites

This topic is 1110 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Create an account

Register a new account

• ### Forum Statistics

• Total Topics
628718
• Total Posts
2984375
• ### Similar Content

• Energy particles being harnessed by collection multi-hedron energy matrix. Whuuuttt?
Love it :)
• By AndySv
Total Music Collection (http://u3d.as/Pxo)   THE COLLECTION CONTAINS:   Mega Game Music Collection   Universal Music Collection   Huge library of high quality music for any project! All at an incredibly low price!   - 2,5GB of high quality audio - 100+ different music tracks - Loop and short versions   Action, fantasy, casual, horror, puzzle, epic, dramatic, romantic, positive, inspiring, motivational and more!
• By Dafu
FES Retro Game Framework is now available on the Unity Asset Store for your kind consideration!
FES was born when I set out to start a retro pixel game project. I was looking around for an engine to try next. I tried a number of things, from GameMaker, to Fantasy Consoles, to MonoGame and Godot and then ended up back at Unity. Unity is just unbeatable in it's cross-platform support, and ease of deployment, but it sure as heck gets in the way of proper retro pixel games!
So I poured over the Unity pipeline and found the lowest levels I could tie into and bring up a new retro game engine inside of Unity, but with a completely different source-code-only, classic game-loop retro blitting and bleeping API. Months of polishing and tweaking later I ended up with FES.
Some FES features:
Pixel perfect rendering RGB and Indexed color mode, with palette swapping support Primitive shape rendering, lines, rectangles, ellipses, pixels Multi-layered tilemaps with TMX file support Offscreen rendering Text rendering, with text alignment, overflow settings, and custom pixel font support Clipping Sound and Music APIs Simplified Input handling Wide pixel support (think Atari 2600) Post processing and transition effects, such as scanlines, screen wipes, screen shake, fade, pixelate and more Deploy to all Unity supported platforms I've put in lots of hours into a very detail documentation, you can flip through it here to get an better glimpse at the features and general overview: http://www.pixeltrollgames.com/fes/docs/index.html
FES is carefully designed and well optimized (see live stress test demo below). Internally it uses batching, it chunks tilemaps, is careful about memory allocations, and tries to be smart about any heavy operations.
Please have a quick look at the screenshots and live demos below and let me know what you think! I'd love to hear some opinions, feedback and questions!
I hope I've tickled your retro feels!

More images at: https://imgur.com/a/LFMAc
Live demo feature reel: https://simmer.io/@Dafu/fes
Live blitting stress test: https://simmer.io/@Dafu/fes-drawstress
Unity Asset Store: https://www.assetstore.unity3d.com/#!/content/102064

View full story
• By Dafu
FES Retro Game Framework is now available on the Unity Asset Store for your kind consideration!
FES was born when I set out to start a retro pixel game project. I was looking around for an engine to try next. I tried a number of things, from GameMaker, to Fantasy Consoles, to MonoGame and Godot and then ended up back at Unity. Unity is just unbeatable in it's cross-platform support, and ease of deployment, but it sure as heck gets in the way of proper retro pixel games!
So I poured over the Unity pipeline and found the lowest levels I could tie into and bring up a new retro game engine inside of Unity, but with a completely different source-code-only, classic game-loop retro blitting and bleeping API. Months of polishing and tweaking later I ended up with FES.
Some FES features:
Pixel perfect rendering RGB and Indexed color mode, with palette swapping support Primitive shape rendering, lines, rectangles, ellipses, pixels Multi-layered tilemaps with TMX file support Offscreen rendering Text rendering, with text alignment, overflow settings, and custom pixel font support Clipping Sound and Music APIs Simplified Input handling Wide pixel support (think Atari 2600) Post processing and transition effects, such as scanlines, screen wipes, screen shake, fade, pixelate and more Deploy to all Unity supported platforms I've put in lots of hours into a very detail documentation, you can flip through it here to get an better glimpse at the features and general overview: http://www.pixeltrollgames.com/fes/docs/index.html
FES is carefully designed and well optimized (see live stress test demo below). Internally it uses batching, it chunks tilemaps, is careful about memory allocations, and tries to be smart about any heavy operations.
Please have a quick look at the screenshots and live demos below and let me know what you think! I'd love to hear some opinions, feedback and questions!
I hope I've tickled your retro feels!

More images at: https://imgur.com/a/LFMAc
Live demo feature reel: https://simmer.io/@Dafu/fes
Live blitting stress test: https://simmer.io/@Dafu/fes-drawstress
Unity Asset Store: https://www.assetstore.unity3d.com/#!/content/102064
• By Dafu
Hello all,
I've been hard at work on a new retro pixel-perfect framework called FES Retro Game Framework. It is now available on the Unity Asset Store for your kind consideration!
FES was born when I set out to start a retro pixel game project. I was looking around for an engine to try next. I tried a number of things, from GameMaker, to Fantasy Consoles, to MonoGame and Godot and then ended up back at Unity. Unity is just unbeatable in it's cross-platform support, and ease of deployment, but it sure as heck gets in the way of proper retro pixel games!
So I poured over the Unity pipeline and found the lowest levels I could tie into and bring up a new retro game engine inside of Unity, but with a completely different source-code-only, classic game-loop retro blitting and bleeping API. Months of polishing and tweaking later I ended up with FES.
Some FES features:
Pixel perfect rendering RGB and Indexed color mode, with palette swapping support Primitive shape rendering, lines, rectangles, ellipses, pixels Multi-layered tilemaps with TMX file support Offscreen rendering Text rendering, with text alignment, overflow settings, and custom pixel font support Clipping Sound and Music APIs Simplified Input handling Wide pixel support (think Atari 2600) Post processing and transition effects, such as scanlines, screen wipes, screen shake, fade, pixelate and more Deploy to all Unity supported platforms I've put in lots of hours into a very detail documentation, you can flip through it here to get an better glimpse at the features and general overview: http://www.pixeltrollgames.com/fes/docs/index.html
FES is carefully designed and well optimized (see live stress test demo below). Internally it uses batching, it chunks tilemaps, is careful about memory allocations, and tries to be smart about any heavy operations.
Please have a quick look at the screenshots and live demos below and let me know what you think! I'd love to hear some opinions, feedback and questions!
I hope I've tickled your retro feels!

More images at: https://imgur.com/a/LFMAc
Live demo feature reel: https://simmer.io/@Dafu/fes
Live blitting stress test: https://simmer.io/@Dafu/fes-drawstress
My own game I started working on using FES, a roguelike, very early: https://simmer.io/@Dafu/merl
Unity Asset Store: https://www.assetstore.unity3d.com/#!/content/102064

• 25
• 11
• 10
• 14
• 14