Page 2 of 2
Re: how to create an 2d block-world?
Posted: Sat May 31, 2014 4:46 am
by Luke100000
Thanks micha. It is possible, that there are less caves, not smaller only less? Beause when I generate a world with 50% caves, it looks little stranges...
And the seed of love.math.noise can't work, it has no seed. Can I anywhere else set the seed of love.math.noise?
Re: how to create an 2d block-world?
Posted: Sat May 31, 2014 5:44 am
by MGinshe
Luke100000 wrote:Thanks micha. It is possible, that there are less caves, not smaller only less? Beause when I generate a world with 50% caves, it looks little stranges...
And the seed of love.math.noise can't work, it has no seed. Can I anywhere else set the seed of love.math.noise?
the value(s) you pass into love.math.noise()
are the seed:
Code: Select all
local w, h = 100, 100
local world = {}
for x = 1, w, 1 do
world[x] = {}
for y = 1, h, 1 do
world[x][y] = love.math.noise(x, y)
end
end
Re: how to create an 2d block-world?
Posted: Sat May 31, 2014 9:00 am
by Robin
And as for less caves, that was the threshold micha was talking about. You can then increase the scale, otherwise the caves would become smaller as well.
Re: how to create an 2d block-world?
Posted: Sat May 31, 2014 10:38 am
by Luke100000
I think I understood this.
Re: how to create an 2d block-world?
Posted: Sat May 31, 2014 12:43 pm
by micha
I updated my demo a bit, so you can play around with the values.
Press up/down/left/right to change the scale of the noise (similar to zooming in and out)
Press w/s to change the threshold value (=ratio of green to blue blocks)
Press a/d to change the seed.
Edit: Press space to set x-scale and y-scale to the same value.
As the others pointed out already, love.math.noise does not have a random seed. What I did instead is added a third argument to the function call. That means that in reality I use a three-dimensional noise, but fix one of the three values. That way I get a two-dimensional noise and I can use the third value as a seed.