Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local size = 4 -- Больше 4 начинается мерцание некоторых линий
- local x0,y0 = 160,50
- local component = require("component")
- local gpu = component.gpu
- local term = require('term')
- function line(x1,y1,x2,y2)
- x= x1
- y= y1
- for i = 1 , math.floor( ( (x2-x1 )^2+( y1-y2 )^2)^0.5) do
- gpu.set(math.floor(x),math.floor(y),'█')
- rad = math.atan2(y1-y2,x2-x1)
- x = x + math.cos(rad)
- y = y - math.sin(rad)
- end
- end
- local t = {}
- function rnd()
- if math.random(0,1) == 0 then
- return -1
- else
- return 1
- end
- end
- for i = 1, size do
- t[i] = {['x'] = math.random(1,120),['y'] = math.random(1,50),['dx'] = rnd(),['dy'] = rnd()}
- end
- term.clear()
- while true do
- for i = 1, size do
- t[i].x = t[i].x + t[i].dx
- t[i].y = t[i].y + t[i].dy
- if t[i].x > x0 then t[i].dx = -1 end
- if t[i].y > y0 then t[i].dy = -1 end
- if t[i].x < 1 then t[i].dx = 1 end
- if t[i].y < 1 then t[i].dy = 1 end
- end
- for i = 1, size-1 do
- line(t[i].x,t[i].y,t[i+1].x,t[i+1].y)
- end
- line(t[1].x,t[1].y,t[size].x,t[size].y)
- os.sleep(0.001)
- term.clear()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement