Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Draws an animated sinewave
- m = peripheral.wrap("right")
- local theta = 0
- local yvalues = {}
- function draw()
- calc()
- render()
- end
- function calc()
- x,y = m.getSize()
- amplitude = math.floor(y/2) -2
- period = x/2
- dx = (math.pi*2) / period
- theta = theta + .02
- for i=0, x do
- yvalues[i] = math.sin(theta) * amplitude
- theta = theta + dx
- end
- end
- function render()
- m.setBackgroundColor(colors.black)
- m.clear()
- for i=1, #yvalues do
- m.setCursorPos(i, (y/2)+ math.floor(yvalues[i]) +1)
- m.blit(" ","0", "0")
- end
- end
- while true do
- draw()
- sleep(.1)
- end
Add Comment
Please, Sign In to add comment