Page 1 of 2
how to create an 2d block-world?
Posted: Wed May 28, 2014 2:33 pm
by Luke100000
I want to create an infinite 2d world, made of blocks ( you see the world from the side!). I split the world into 16*16 chunks and I generate them if the player needs them. My problems are caves. How I can generate caves totally randomly, maybe sometimes dirt on the ground and something like that. The same problem with bigger dungeons.
My idee: Creating a second map with caves, dungeons, villages and other big stuff and save them. When the chunk is creating, it also load the save of the second map.
Please help!
Re: how to create an 2d block-world?
Posted: Wed May 28, 2014 6:57 pm
by davisdude
I don't know if this belongs in Projects and Demos.
Anyway, that has a LOT to do with several things: how many caves you want; what you want them to look like; etc.
This article might help for generating the "cave" part. As for the land generation, I can't find anything too useful, but most of it has to be "custom" to how you want it to be, from my understanding.
Re: how to create an 2d block-world?
Posted: Thu May 29, 2014 10:47 am
by Luke100000
davisdude wrote:I don't know if this belongs in Projects and Demos.
Anyway, that has a LOT to do with several things: how many caves you want; what you want them to look like; etc.
This article might help for generating the "cave" part. As for the land generation, I can't find anything too useful, but most of it has to be "custom" to how you want it to be, from my understanding.
It's a Project of me.
The caves should look like
Minecraft, only 2d.
I can't create caves wich goes over some chunks.
On the page of this link is a methode, but I can't use it...
Re: how to create an 2d block-world?
Posted: Thu May 29, 2014 11:23 am
by Sheepolution
Luke100000 wrote:
It's a Project of me.
This board is to show what you made. If you need help with what you're making, you post it on Support and Development.
Re: how to create an 2d block-world?
Posted: Thu May 29, 2014 11:25 am
by DaedalusYoung
Use
love.math.noise to create your caves. This will give you simplex noise, similar to what Minecraft uses/used to use to create terrain.
Re: how to create an 2d block-world?
Posted: Thu May 29, 2014 2:11 pm
by Jampiles
Sounds like the link Davisdude posted should be of some use to you.
Also check out
this which was used by a fellow love2d user to create
this module.
Re: how to create an 2d block-world?
Posted: Thu May 29, 2014 2:38 pm
by Luke100000
Jampiles wrote:Sounds like the link Davisdude posted should be of some use to you.
Also check out
this which was used by a fellow love2d user to create
this module.
Thanks, this is cool, but I want a generator who can create some chunks now and some chunks maybe tomorow and create another part of the same cave.
Use love.math.noise to create your caves. This will give you simplex noise, similar to what Minecraft uses/used to use to create terrain.
love.math.noise is not math.random, isn't? When I say print(love.math.noise(1,1)) it returns the same value when I type print(love.math.noise(1,1)) another time?
I think, this was what I wanted.
Luke100000 wrote:It's a Project of me.
This board is to show what you made. If you need help with what you're making, you post it on Support and Development.
oh.
Ok, next time I will know where I ask my questions.
Re: how to create an 2d block-world?
Posted: Thu May 29, 2014 8:11 pm
by micha
Luke100000 wrote:love.math.noise is not math.random, isn't? When I say print(love.math.noise(1,1)) it returns the same value when I type print(love.math.noise(1,1)) another time?
I think, this was what I wanted.
You are right. love.math.noise is deterministic. That means each time you call it with the same input, you will get the same output. For your purpose this is probably the easiest way to introduce "random but reproducible" noise.
Re: how to create an 2d block-world?
Posted: Thu May 29, 2014 8:34 pm
by davisdude
Luke100000 wrote:It's a Project of me.
It should still be under support and development. You don't have anything to show yet. Yet.
Luke100000 wrote:I can't create caves wich goes over some chunks.
On the page of this link is a methode, but I can't use it...
You could just subtract blocks from a certain area to make the cave.
As for your problem,
this article seems to have an answer you want, but it's not in Lua.
Re: how to create an 2d block-world?
Posted: Thu May 29, 2014 9:00 pm
by micha
I just wanted to test myself how difficult it would be to generate a 2d block-world from love.math.noise. Here is what I came up with.
- blockworld.png (4.08 KiB) Viewed 4237 times
In each point it simply uses the love.math.noise and checks if it is larger than a threshold. If so, then soil type 1 is assigned, otherwise it is soil type 2.
The .love is not interactive, but you can play around with the values in the source code:
- You can play around with the values for the threshold. With it you can control how much of one soil type you have. It should be between 0 and 1.
- You can also change the scale factor, which controls how big the clusters are. You could even introduce two scale factors for x- and y-direction to create an anisotropic world.
- Also you can change the seed value. If you run the game with the same seed, you will always get the same field.