I’ve been designing an infinite line scrolling down a screen. However, there are 2 problems. First, the intersections are don’t look like exact intersections. Secondly, the line flickers occasionally. Could someone help improve this?
Here is the code:
-- Use this function to perform your initial setup
function setup()
print("Hello World!")
linex={}
liney={}
xcounter = 0
ycounter = 0
linex[1] = math.random(WIDTH/10,WIDTH/1.1)
liney[1] = ycounter
for i=2,6 do
x = math.random(WIDTH/10,WIDTH/1.1)
y = math.random(HEIGHT/5,HEIGHT/4)
ycounter = ycounter + y
linex[i] = x
liney[i] = ycounter
end
end
-- This function gets called once every frame
function draw()
strokeWidth(10)
-- This sets a dark background color
background(40, 40, 50)
-- This sets the line thickness
-- Do your drawing here
for i = 1,5 do
line(linex[i],liney[i],linex[i+1],liney[i+1])
if(liney[2]<0)then
table.remove(liney,1)
table.remove(linex,1)
x = math.random(WIDTH/10,WIDTH/1.1)
y = math.random(HEIGHT/5,HEIGHT/4)
linex[6] = x
liney[6] = y+HEIGHT
end
for i=1,5 do
liney[i] = liney[i] -3
end
end
end