Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local X, Y, DIRECTION, LONGUEUR, COULEUR = 1, 2, 3, 4, 5
- local NORD, EST, SUD, OUEST = 1, 2, 3, 4
- term.clear()
- term.setBackgroundColor(1)
- term.setTextColor(32768)
- term.clear()
- term.setCursorPos(1,1)
- local monitor = peripheral.wrap( "top" )
- local W, H = monitor.getSize()
- local lines = { }
- function createLine(lines)
- direction = math.random(1,4)
- if direction == NORD then
- x = math.random(1,W)
- y = H
- elseif direction == EST then
- x = 1
- y = math.random(1,H)
- elseif direction == SUD then
- x = math.random(1,W)
- y = 1
- elseif direction == OUEST then
- x = W
- y = math.random(1,H)
- end
- line = {x, y, direction, math.random(2,6), math.random(1,32769)}
- -- line = {2, 10, 1, 2, colors.black}
- table.insert(lines, line)
- end
- function moveLines(lines)
- for i, l in ipairs(lines) do
- if l[DIRECTION] == NORD then
- if inBounds(l[X],l[Y]-l[LONGUEUR]) then
- paintutils.drawPixel(l[X],l[Y], colors.white)
- paintutils.drawPixel(l[X],l[Y]-l[LONGUEUR], l[COULEUR])
- l[Y] = l[Y]-1
- elseif inBounds(l[X],l[Y]-l[LONGUEUR]) == false and l[LONGUEUR]>1 then
- l[LONGUEUR] = l[LONGUEUR]-1
- paintutils.drawPixel(l[X],l[Y], colors.white)
- paintutils.drawPixel(l[X],l[Y]-l[LONGUEUR], l[COULEUR])
- l[Y] = l[Y]-1
- else
- table.remove(lines,i)
- end
- elseif l[DIRECTION] == EST then
- if inBounds(l[X]+l[LONGUEUR],l[Y]) then
- paintutils.drawPixel(l[X],l[Y], colors.white)
- paintutils.drawPixel(l[X]+l[LONGUEUR],l[Y], l[COULEUR])
- l[X] = l[X]+1
- elseif inBounds(l[X]+l[LONGUEUR],l[Y]) == false and l[LONGUEUR]>1 then
- l[LONGUEUR] = l[LONGUEUR]-1
- paintutils.drawPixel(l[X],l[Y], colors.white)
- paintutils.drawPixel(l[X]+l[LONGUEUR],l[Y], l[COULEUR])
- l[X] = l[X]+1
- else
- table.remove(lines,i)
- end
- elseif l[DIRECTION] == SUD then
- if inBounds(l[X],l[Y]-l[LONGUEUR]) then
- paintutils.drawPixel(l[X],l[Y], colors.white)
- paintutils.drawPixel(l[X],l[Y]+l[LONGUEUR], l[COULEUR])
- l[Y] = l[Y]+1
- elseif inBounds(l[X],l[Y]+l[LONGUEUR]) == false and l[LONGUEUR]>1 then
- l[LONGUEUR] = l[LONGUEUR]-1
- paintutils.drawPixel(l[X],l[Y], colors.white)
- paintutils.drawPixel(l[X],l[Y]+l[LONGUEUR], l[COULEUR])
- l[Y] = l[Y]+1
- else
- table.remove(lines,i)
- end
- elseif l[DIRECTION] == OUEST then
- if inBounds(l[X]-l[LONGUEUR],l[Y]) then
- paintutils.drawPixel(l[X],l[Y], colors.white)
- paintutils.drawPixel(l[X]-l[LONGUEUR],l[Y], l[COULEUR])
- l[X] = l[X]-1
- elseif inBounds(l[X]-l[LONGUEUR],l[Y]) == false and l[LONGUEUR]>1 then
- l[LONGUEUR] = l[LONGUEUR]-1
- paintutils.drawPixel(l[X],l[Y], colors.white)
- paintutils.drawPixel(l[X]-l[LONGUEUR],l[Y], l[COULEUR])
- l[X] = l[X]-1
- else
- table.remove(lines,i)
- end
- end
- end
- end
- function inBounds(x,y)
- if x>=0 and x<=W+1 and y>=0 and y<=H+1 then
- return true
- end
- return false
- end
- createLine(lines)
- createLine(lines)
- createLine(lines)
- createLine(lines)
- while table.getn(lines) ~= 0 do
- if table.getn(lines) < 40 then
- createLine(lines)
- end
- moveLines(lines)
- sleep(0.01)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement