Posted 09 May 2013 - 01:49 PM
To pass the time in my IT class, I scripted this nice rainbow animation. Here's the code: http://pastebin.com/YL5rEicS
I wrote the program in moonscript, then converted it to lua for CC. I would consider it a bit more readable, so if you're curious, here's the moonscript:
I wrote the program in moonscript, then converted it to lua for CC. I would consider it a bit more readable, so if you're curious, here's the moonscript:
Spoiler
local *
time = 0
period = 0.05
updateTimer = os.startTimer period
local rainbow
with colors
rainbow = {
.black
.red
.orange
.yellow
.green
.blue
.purple
.black
}
draw = ->
with term
w,h = term.getSize!
for x=1, w
for i=1, #rainbow
.setBackgroundColor rainbow[i]
for y=i*3 - 2, i*3
y += math.sin(x / 15 + time) * 3
.setCursorPos x, y
.write ' '
while true
_, timer = os.pullEvent 'timer'
if timer == updateTimer
draw!
time += 0.5
updateTimer = os.startTimer period