Page 1 of 1
love.math.noise
Posted: Wed Feb 24, 2016 9:26 pm
by dalmuti
Code: Select all
for i=1, 10, do
value = love.math.noise(i)
print(value)
end
I'm trying to create a Perlin noise function. From what I gathered this is a build in function in lua that given an x value it returns a value between 0 and 1, but when I run the loop above I get the same value of .5 for every i variable input into the function. Am I wrong to think that this can be substituted instead of the random number generator? and why I cant get different values when inputting i into love.math.noise(i)?
Re: love.math.noise
Posted: Wed Feb 24, 2016 9:43 pm
by Robin
What if you try love.math.noise(i/10) ?
Re: love.math.noise
Posted: Thu Feb 25, 2016 3:14 am
by Zarty55
I've had the same problem as you.
https://bitbucket.org/account/notificat ... -arguments
The solution is to pass non-integer values to the function.
Re: love.math.noise
Posted: Sat Feb 27, 2016 9:27 pm
by dalmuti
thanks for the help, ironed out a few things with that, but i'm running into the issue that when I close the program and reopen it I get the same values. How can I have a random set of numbers each time?
Re: love.math.noise
Posted: Sat Feb 27, 2016 9:46 pm
by zorg
Try multiplying it with love.math.random.
Re: love.math.noise
Posted: Sat Feb 27, 2016 10:33 pm
by slime
noise is supposed to give the same output given the same input. You could add an offset to the arguments which is randomized at startup. Something like this:
Code: Select all
function love.load()
local offset = love.math.random() * 100000
for i=1, 10 do
local value = love.math.noise(offset + i / 10)
end
end