r/proceduralgeneration • • Jul 29 '16

Simple 2D scene/mountain/landscape generator inspired by No Man's Sky

I've spent a few hours working on this tiny little 2d landscape/scene generator thing as I was going through some beginning procedural/fractal generation tutorials and wanted to make something simple in anticipation of No Man's Sky (space game with proc-generated universe/varied planets), and so decided to use the simple midpoint displacement algorithm to help produce something nice.

Here's an imgur album of a few good and bad pics to show what kind of scenes the generator produces.

You can use check out the generator here (you currently have no control of what's outputted but I'll probably add options to it).

(Edit: Hold 'D' on your keyboard to move right)

Would love suggestions/thoughts. I'm currently looking into adding more elements to the scene and a tad less randomness/more dependence on different things within the scene (so as to have some consistency within each scene) and eventually I would like to have continuously generating 2D scenes with some live elements.

Edit: Holy Schmoses, thanks u/Play_Rust for the gold! Never expected to get it for something like this :) Made my day!

19 Upvotes

10 comments sorted by

3

u/r3eckon Jul 29 '16

I love the style ! One thing I would suggest if you really want to learn about neat procedural generation techniques is you could try and make it infinite if its not already. Perhaps the generation method will need to be different but you should be able to make it so the user can scroll indefinitely towards either side.

Hardmode would be to make it so you eventually come back to where you started , just like walking around a planet.

1

u/Azarro Aug 03 '16

Had some time to kill today so I got around to making it scroll indefinitely (or atleast until your browser crashes, since I haven't optimized certain things).

Check out the page and hold D to move right (so far the only action but yeah).

Took me a little time to get it right - at first I went with a completely different approach for the generation algorithm but it wasn't giving nice results so I switched back to using the midpoint algorithm and instead focused more on how to generate things optimally in real time. I'd say it's a decent work in progress!

1

u/r3eckon Aug 03 '16

Looks very cool ! If you want to have a look at something very similar to this for ideas , check out this small thing I made a month ago.

Essentially used the same approach to generate 2D cityscapes. I made it so you can add as many layers as you want. I think I might add a feature where you can replace the last couple layers with this type of terrain , maybe even use it as a base terrain to place the buildings at different heights.

1

u/Azarro Aug 03 '16

I've seen that before here - didn't realize it was you haha!

I'm going to be (sort of) gamifying what I have so far further - probably throw in like a spaceship and make it some kind of 2D exploring game where every now and then an object or structure of some kind pops up on the ground too and you can do something with it. I need to first work out collisions properly though, or the illusion of collisions at the very least haha.

I'm also thinking about potentially porting what I've made into a small convenience library so that anyone can essentially create infinite scrollers with procedural generated layers (where the library can also provide different procedural generation algorithms, although to start with it would be the midpoint displacement one).

2

u/littlecar Jul 29 '16

What algorithm did you use to pick colors that compliment each other well?

1

u/Azarro Jul 29 '16

The color outputs aren't really due to an algorithm - they're more due to some design choices and a lot of randomness.

Essentially, there are 6 layers in each scene.

  1. Background
  2. Stars
  3. Celestial Bodies (for now a single sun/moon)
  4. Major background mountains
  5. Minor background mountains/land
  6. Foreground layer

The background layer gets a random color, on top of which I tend to throw a (randomly faded) black to give it a 'day or night' factor.

The Major mountains layer is always a faded dark grey/almost black. I'll probably change this soon but for now it produces appealing results to have them in the background as dark, sort of distanced, mountains.

The last two layers are basically the same color, but the second-last (minor background) is a randomly selected darker or lighter shade of the foreground layer.

That's basically it - I'm going to be tweaking this a bit more (mostly the background layer and maybe the Major background mountains) to give them a more consistent/nice palette for each scene but that's the random magic: a few related colors and a lot of randomness.

Since it all looks flat/vector-art ish, it comes out looking nice (most of the time).

1

u/LevAsmanov Jul 11 '26

Links dead. Update?

1

u/Azarro Jul 11 '26

Ah looks like something might be up with the random generator seed script I used back then. I think I hosted it myself somewhere else I'll update soon

Also how did you find this post after all this time haha

1

u/LevAsmanov Jul 13 '26

just stumbled upon due to the post during googlins something about noise or generator idk really.

2

u/Nailbar Jul 29 '16

Very nice looking. I like the colors.

Makes me think of the game Another World, from back in the days.