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:

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

Post 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... :crazy:
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?
User avatar
MGinshe
Prole
Posts: 31
Joined: Sun Apr 17, 2011 3:50 am
Location: New Zealand

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

Post 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... :crazy:
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
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

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

Post 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.
Help us help you: attach a .love.
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 »

:awesome: I think I understood this.
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 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.
Attachments
randomBlock2.love
(707 Bytes) Downloaded 127 times
Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests