You need a sin wave that has a random frequency this will keep the bends in the road but it will make sure that at some point the road will return to the center
frequency.changeRate = ran(10)*3.14159/180
frequency = frequency + frequency.changeRate
road.x = sin(frequency) * maximum.offsetFromCenter
replace whatever you had used to define the center of the road with the above
Edit:
I put together an example for you to see how it works take a look a label main
screenX = 640
screenY = 512
maxRoadX = 160
bendRate = 3.14159/screenY
bendFrequency = 0
dim roadX(screenY)
open window screenX, screenY
window origin "cc"
setrgb 0, 000, 140, 000
for a = 0 to screenY
roadX(a) = cos(bendFrequency) * maxRoadX
bendFrequency = bendFrequency + bendRate
next a
label main
drawScreen()
roadX(screenY) = cos(bendFrequency) * maxRoadX
bendFrequency = bendFrequency + bendRate
goto main
sub drawScreen()
setdispbuf draw
draw = 1 - draw
setdrawbuf draw
clear window
setrgb 1, 110, 80, 40
for a = 1 to screenY
b = 256 - a
line roadX(a)-100,b to roadX(a)+100,b
next a
setrgb 1, 125, 90, 50
for a = 1 to screenY
b = 256 - a
line roadX(a)-85,b to roadX(a)-15,b
line roadX(a)+85,b to roadX(a)+15,b
next a
setrgb 1, 150, 100, 60
for a = 1 to screenY
b = 256 - a
line roadX(a)-30,b to roadX(a)-70,b
line roadX(a)+30,b to roadX(a)+70,b
roadX(a-1) = roadX(a)
next a
end sub