Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Donut.C Ported to computercraft by nonogamer9
- -- Original C Code By Andy Sloane
- local A = 0
- local B = 0
- local z = {}
- local b = {}
- local screenWidth, screenHeight = term.getSize()
- local function getChar(N)
- local chars = ".,-~:;=!*#$@"
- return chars:sub(math.floor(math.max(N, 1)), math.floor(math.max(N, 1)))
- end
- term.clear()
- term.setCursorPos(1, 1)
- while true do
- -- Reset buffers
- for i = 1, screenWidth * screenHeight do
- b[i] = ' '
- z[i] = 0
- end
- for j = 0, 6.28, 0.07 do
- for i = 0, 6.28, 0.02 do
- local sini = math.sin(i)
- local cosj = math.cos(j)
- local sinA = math.sin(A)
- local sinj = math.sin(j)
- local cosA = math.cos(A)
- local cosj2 = cosj + 2
- local mess = 1 / (sini * cosj2 * sinA + sinj * cosA + 5)
- local cosi = math.cos(i)
- local cosB = math.cos(B)
- local sinB = math.sin(B)
- local t = sini * cosj2 * cosA - sinj * sinA
- local x = math.floor(40 + 30 * mess * (cosi * cosj2 * cosB - t * sinB))
- local y = math.floor(12 + 15 * mess * (cosi * cosj2 * sinB + t * cosB))
- local o = x + screenWidth * y
- local N = 8 * ((sinj * sinA - sini * cosj * cosA) * cosB - sini * cosj * sinA - sinj * cosA - cosi * cosj * sinB)
- if y > 0 and y < screenHeight and x > 0 and x < screenWidth and mess > z[o] then
- z[o] = mess
- b[o] = getChar(N + 1)
- end
- end
- end
- term.setCursorPos(1, 1)
- for k = 1, screenWidth * screenHeight do
- term.write(b[k])
- if k % screenWidth == 0 then
- term.setCursorPos(1, k / screenWidth + 1)
- end
- end
- A = A + 0.08
- B = B + 0.06
- os.sleep(0.03)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement