Ive been going at this all day to try and get one of those pretty noise maps, but pretty much all i get using the love.math.noise function is random values. do i need do something completly different to make on of those?
for reference here is the code i was trying to get to work--
function love.load()
y_resolution = 800
x_resolution = 1400
mesh_data = {}
x = 1
y = 1
love.window.setMode(x_resolution, y_resolution, {resizable=true})
for i = 1, y_resolution, 10 do
for p = 1, x_resolution, 10 do
table.insert(mesh_data, {p, i, love.math.noise(x, y)})
x = x+1
end
y = y + 1
end
end
function love.update(dt)
if love.keyboard.isDown("escape") then
love.event.quit()
end
end
function love.draw()
for i=1, #mesh_data, 1 do
love.graphics.setColor(mesh_data[3],mesh_data[3],mesh_data[3])
love.graphics.circle("fill", mesh_data[1], mesh_data[2], 5)
end
end
like i said, for some reason it just looks like circles with random shades instead of the uniformity i was looking for. help please?
Hwlp with setting up perlin noise gen?
-
- Prole
- Posts: 1
- Joined: Fri Jan 03, 2025 8:01 am
- 417_TheFog
- Prole
- Posts: 8
- Joined: Sun Dec 29, 2024 1:37 pm
Re: Hwlp with setting up perlin noise gen?
well love.math.noise gives random values because you are using it absolutley randomly. it is more mess_data then mesh_data. better use it like this (literally stole this from https://love2d.org/wiki/love.math.noise):
Code: Select all
local grid = {}
local function generateNoiseGrid() --fills grid with noise
local baseX = 10000 * love.math.random() --seed thingo.
local baseY = 10000 * love.math.random()
for y = 1, 100 do
grid[y] = {}
for x = 1, 100 do
grid[y][x] = love.math.noise(baseX+0.1*x, baseY+0.1*y) --table.insert wont work. better use it like this. '0.1' is noiseness. Yours noiseness is 0.
end
end
end
function love.load()
generateNoiseGrid()
end
function love.keypressed() --convient debug.
generateNoiseGrid()
end
function love.draw()
local tileSize = 8
for y = 1, #grid do
for x = 1, #grid[y] do
love.graphics.setColor(0.618, 0.618, 0.618, grid[y][x])
love.graphics.circle("fill", x*tileSize, y*tileSize, grid[y][x]*7) --now brighter means bigger cus why not lol.
end
end
end
Who is online
Users browsing this forum: Bing [Bot] and 7 guests