Posted 28 June 2015 - 09:38 AM
The following code i meant to show the camera zooming through a 3D star field but only renders once and then clears.
os.loadAPI("CCG/renderer")
local mon = peripheral.wrap("left")
mon.setTextScale(0.5)
local w, h = mon.getSize()
local ren = renderer.create(mon, 1, 1, w, h)
ren:clear()
local stars = {}
local speed = 20
for i = 1, 128 do
stars[i] = {math.random(w), math.random(h), math.random() + 0.001}
end
local lastFrame = os.clock()
local delta = 0
while true do
local thisFrame = os.clock()
delta = thisFrame - lastFrame
lastFrame = thisFrame
ren:clear()
for i = 1, #stars do
stars[i][3] = stars[i][3] - speed * delta
local x = stars[i][1]
local y = stars[i][2]
local z = stars[i][3]
if z <= 0 then
stars[i] = {math.random(w), math.random(h), math.random() + 0.001}
end
ren:pixel(x / z, y / z, 1, 1, 1, " ")
end
ren:update()
sleep(0.5)
end