Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local component = require('component')
- local term = require('term')
- local camera = component.camera
- local gpu = component.gpu
- local color = {
- 0x000000,
- 0x111111,
- 0x222222,
- 0x333333,
- 0x444444,
- 0x555555,
- 0x666666,
- 0x777777,
- 0x000040,
- 0x000080,
- 0x002480,
- 0x0000BF,
- 0x0024BF,
- 0x002400,
- 0x004900,
- 0x006D00,
- 0x009200,
- 0x00B600,
- 0x33DB00,
- 0x99FF00,
- 0xCCFF00,
- 0xFFDB00,
- 0xFFB600,
- 0xFF9200,
- 0xFF6D00,
- 0xFF4900,
- 0xFF2400,
- 0xFF0000
- }
- function render(size, zoom, fog, side) -- возвращает картинку и расстояние до первого блока напротив камеры
- local tbl = {}
- local pixel, d
- if not fog then
- fog = 1.2
- end
- if side == 0 then
- look = camera.distanceDown
- elseif side == 1 then
- look = camera.distanceUp
- else
- look = camera.distance
- end
- local yp = 1
- for j = -zoom, zoom, size do
- tbl[yp] = {}
- for i = zoom, -zoom, -size do
- d = look(i, 0-j)
- pixel = 1
- if d > 0 then
- pixel = 2+((#color-1)-math.min(#color-1, (d/fog)))
- end
- table.insert(tbl[yp], color[math.floor(pixel)])
- end
- yp = yp + 1
- end
- return tbl, look(0, 0)
- end
- local function printX4(data)
- term.clear()
- for i = 1, #data, 2 do
- for j = 1, #data[i] do
- gpu.setBackground(data[i][j])
- gpu.setForeground(data[i+1][j])
- if i == 1 then
- gpu.set(j, i, '-')
- else
- gpu.set(j, i-(i/2), '-')
- end
- end
- end
- end
- local fgrnd = gpu.getForeground()
- local bgrnd = gpu.getBackground()
- printX4(render(0.039, 1, 0.9))
- gpu.setForeground(fgrnd)
- gpu.setBackground(bgrnd)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement