' make a pyramid by NaochanON
' Challenge of the month July 2012
Init()
makecubes()
input()
Controls.ButtonClicked=movecubes
Sub movecubes
If MM>0 Then
reposition() ' hide (remove) cubes
EndIf
div=30 ' like animation dividing
MM= Controls.GetTextBoxText(box) ' step number
If MM>11 Then
MM=10
ElseIf MM<2 then
MM=2
EndIf
'-------------------------------------------------- stacking ---------------------------------------------
st=1
for N=MM To 1 Step -1
for i=st To st+N*N-1
NewX=X1+(MM-N)*R0/4+R0*(Math.Remainder((i-st),N))-R0*(Math.Floor((i-st)/N))/2
NewY=Y1-(MM-N)*3*R0/4+R0*(Math.Floor((i-st)/N))/2
Stacking()
Sound.PlayClick()
EndFor
st=st+N*N
endfor
EndSub
Sub stacking
dx=(NewX-X0)/div ' moving length
dy=(NewY-Y0)/div
For j=1 To div
X=X0+dx*j
Y=Y0+dy*j
Shapes.Move(a[i],x,y)
Shapes.Move(b[i],x,y)
Shapes.Move(c[i],x,y)
Shapes.Move(d[i],x+R0,y)
Shapes.Move(e[i],x+R0,y)
Shapes.Move(f[i],x+dxy,y-dxy)
Shapes.Move(g[i],x+R0,y)
Shapes.Move(h[i],x+R0+dxy,y-dxy)
Program.Delay(10)
EndFor
EndSub