how to create an 2d block-world?

Showcase your libraries, tools and other projects that help your fellow love users.
User avatar
Luke100000
Party member
Posts: 232
Joined: Mon Jul 22, 2013 9:17 am
Location: Austria
Contact:

how to create an 2d block-world?

Post 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! :( :death:
davisdude
Party member
Posts: 1154
Joined: Sun Apr 28, 2013 3:29 am
Location: North Carolina

Re: how to create an 2d block-world?

Post 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.
GitHub | MLib - Math and shape intersections library | Walt - Animation library | Brady - Camera library with parallax scrolling | Vim-love-docs - Help files and syntax coloring for Vim
User avatar
Luke100000
Party member
Posts: 232
Joined: Mon Jul 22, 2013 9:17 am
Location: Austria
Contact:

Re: how to create an 2d block-world?

Post 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...
User avatar
Sheepolution
Party member
Posts: 264
Joined: Mon Mar 04, 2013 9:31 am
Location: The Netherlands
Contact:

Re: how to create an 2d block-world?

Post 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.
User avatar
DaedalusYoung
Party member
Posts: 413
Joined: Sun Jul 14, 2013 8:04 pm

Re: how to create an 2d block-world?

Post 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.
Jampiles
Prole
Posts: 1
Joined: Thu May 01, 2014 1:40 pm

Re: how to create an 2d block-world?

Post 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.
User avatar
Luke100000
Party member
Posts: 232
Joined: Mon Jul 22, 2013 9:17 am
Location: Austria
Contact:

Re: how to create an 2d block-world?

Post 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. :o: Ok, next time I will know where I ask my questions.
User avatar
micha
Inner party member
Posts: 1083
Joined: Wed Sep 26, 2012 5:13 pm

Re: how to create an 2d block-world?

Post 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.
davisdude
Party member
Posts: 1154
Joined: Sun Apr 28, 2013 3:29 am
Location: North Carolina

Re: how to create an 2d block-world?

Post 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.
GitHub | MLib - Math and shape intersections library | Walt - Animation library | Brady - Camera library with parallax scrolling | Vim-love-docs - Help files and syntax coloring for Vim
User avatar
micha
Inner party member
Posts: 1083
Joined: Wed Sep 26, 2012 5:13 pm

Re: how to create an 2d block-world?

Post 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
blockworld.png (4.08 KiB) Viewed 4238 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.
Attachments
randomBlock.love
(452 Bytes) Downloaded 210 times
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 2 guests