Here's one that wont flood:
Const TRUE = -1, FALSE = Not TRUE
Screen _NewImage(640, 350, 9): Cls: Randomize Timer
Do
Cls
DrawTerrain 225, 10
Sleep 5
Loop Until InKey$ = Chr$(27)
Sub DrawTerrain (h, modN) ' modN for ruggedness the higher the less smooth
For x = 0 To _Width
If x Mod modN = 0 Then ' adjust mod number for ruggedness the higher the number the more jagged
If h < 350 - modN And h > 50 + modN Then
dy = Rnd * 20 - 10
ElseIf h >= 350 - modN Then
dy = Rnd * -10
ElseIf h <= 50 + modN Then
dy = Rnd * 10
End If
End If
h = h + .1 * dy
Line (x, _Height)-(x, h), 2
Next
End Sub