Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local grid = {}
- local function generateNoiseGrid()
- -- Fill each tile in our grid with noise.
- local baseX = 10000 * love.math.random()
- local baseY = 10000 * love.math.random()
- for y = 1, 120 do
- grid[y] = {}
- for x = 1, 124 do
- grid[y][x] = love.math.noise(baseX+.1*x, baseY+.2*y)
- end
- end
- end
- function love.load()
- generateNoiseGrid()
- end
- function love.keypressed()
- generateNoiseGrid()
- end
- function love.draw()
- local tileSize = 8
- for y = 1, #grid do
- for x = 1, #grid[y] do
- if grid[y][x] <= 0.2 then
- love.graphics.setColor(43/255, 57/255, 232/255, 1)
- elseif grid[y][x] > 0.2 and grid[y][x] <= 0.4 then
- love.graphics.setColor(226/255, 243/255, 98/255, 1)
- else
- love.graphics.setColor(55/255, 195/255, 55/255, 1)
- end
- love.graphics.rectangle("fill", x*tileSize, y*tileSize, tileSize-1, tileSize-1)
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment