Cheers Satchmo,
The algorithm for the whole took a few attempts.
My first idea was to just place the bricks, alightly offset from one another by a random amount. This was rubbish and you could pretty much just let the cow fall down the middle.
My next idea was to use two sine wave functions, one for the centre line and one for the hole "gap", but this was too uniform.
In the end I went for randomly setting a target centre position and hole gap and then randomly adjusting the brick positions towards the target. Here's the code for my brick positioning:
function ManageWalls()
//repositions all walls
CutOff# = screentoworldy(0)
hscale# = 1.5 + ((DropDistance) * 0.001)
for w=0 to MaxWalls
WallSpt = Wall[w].spriteid
wy# = getspritey(WallSpt) + getspriteheight(WallSpt)
//check if brick has moved off screen.
if wy# < CutOff#
//if left wall - calc new width
if wall[w].leftwall=1
//wall is offscreen set next wall down
NewPos# = LowestWall + getspriteheight(WallSpt)
//new wall pair
CurrentPosX = CurrentPosX + ((NextPosX - CurrentPosX)*0.05)
CurrentWidth = CurrentWidth + ((NextWidth - CurrentWidth)*0.05)
//randomizer
CurrentPosX = CurrentPosX * (random(98,102)*0.01)
CurrentWidth = CurrentWidth * (random(98,102)*0.01)
LeftEdge# = CurrentPosX - (CurrentWidth/2.0)
wx# = screentoworldx(LeftEdge# - getspritewidth(WallSpt))
//HOLE
hSpt = HoleSpt[w]
if getspriteexists(hSpt)=1
hscalex# = CurrentWidth / 720.0
setspritescalebyoffset(hSpt,hscalex#,1.5)
hx# = wx# + getspritewidth(WallSpt)
setspriteposition(hSpt,hx#,NewPos#)
endif
//Wall[w].scale = scale#
else
NewPos# = LowestWall
//right wall define gap and calc remaining width
RightEdge# = CurrentPosX + (CurrentWidth/2.0)
wx# = screentoworldx(RightEdge#)
endif
//setspritescale(WallSpt,scale#,hscale#)
setspriteposition(WallSpt,wx#,NewPos#)
//store lowest positioned wall
if NewPos#>LowestWall then LowestWall = NewPos#
//set new centre position
if CurrentPosX>(NextPosX*0.9) and CurrentPosX<(NextPosX*1.1)
NextPosX = (random(10,90)*0.01) * getvirtualwidth()
endif
//set new width
if CurrentWidth>(NextWidth*0.9) and CurrentWidth<(NextWidth*1.1)
NextWidth = MinGap + ((random(0,75)*0.01) * (getvirtualwidth()-MinGap))
endif
//print("Scale OK:"+str(ScaleGood)+" Gap:"+str(Gap#,1))
//print(" Min Gap:"+str(MinGap,1)+" Max Gap:"+str(MaxGap,1))
//sync()
endif
next w
endfunction
I hope it makes sense