Advertisement
Xelostar

Noise Demo 2

Jul 7th, 2018
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.38 KB | None | 0 0
  1. local function drawLines(buffer, noise)
  2.     local size = table.getn(noise[1])
  3.     local width = table.getn(noise)
  4.     for y = 1, size do
  5.         buffer:clear(colors.black)
  6.         for x = 1, width do
  7.             local value = noise[x][y]
  8.             buffer:setPixel(x, value * buffer.y2, colors.lime, colors.lime, " ")
  9.  
  10.             if (x > 1) then
  11.                 buffer:loadLine(x, noise[x-1][y] * buffer.y2, x, value * buffer.y2, colors.lime, " ", colors.lime)
  12.             end
  13.         end
  14.         buffer:drawBuffer(true)
  15.         if (y ~= size) then
  16.             sleep(0.05)
  17.         end
  18.     end
  19. end
  20.  
  21. os.loadAPI("/noise")
  22. os.loadAPI("/bufferAPI")
  23. os.loadAPI("/blittle")
  24. local seed = math.random(1, 10000)
  25. local width, height = term.getSize()
  26. local buffer = bufferAPI.newBuffer(1, 1, width*2, height*3)
  27.  
  28. local chunky = 1
  29. while true do
  30.     chunky = chunky + 1
  31.  
  32.     local noise1 = noise.createNoise(32, 0, chunky, seed)
  33.     local noise2 = noise.createNoise(32, 1, chunky, seed)
  34.     local noise3 = noise.createNoise(32, 2, chunky, seed)
  35.     local noise4 = noise.createNoise(32, 3, chunky, seed)
  36.     local noise = {}
  37.     for y = 1, 32 do
  38.         for x = 1, 32 * 4 do
  39.             if (noise[x] == nil) then noise[x] = {} end
  40.             if (x <= 32) then
  41.                 noise[x][y] = noise1[x][y]
  42.             elseif (x <= 32 * 2) then
  43.                 noise[x][y] = noise2[x - 32][y]
  44.             elseif (x <= 32 * 3) then
  45.                 noise[x][y] = noise3[x - 32 * 2][y]
  46.             else
  47.                 noise[x][y] = noise4[x - 32 * 3][y]
  48.             end
  49.         end
  50.     end
  51.     drawLines(buffer, noise)
  52. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement