Microsoft Small Basic

Program Listing: TWF419
' Challenge of the month October 2013 12 steps by NaochanON
' graphic version CCC587
gui()
calc()

Sub Move_ball
N=math.Floor(math.Log(NN))+1
For i=1 To 12
Shapes.SetText(mes,NN+" : "+text.GetSubText(t112,1,i))
Shapes.Animate(ball,BXY["X"]+40*i,Shapes.GetTop(ball),delay[N])
Program.Delay(delay[N])
dY= Text.GetSubText(t112,i,1)
Shapes.animate(ball, BXY["X"]+40*i,Shapes.GetTop(ball)+40*dY,delay[N])
Program.Delay(delay[N])
EndFor
Shapes.Animate(ball,50+5,50-25,500)
BXY="X="+ Shapes.GetLeft(ball)+";Y="+ Shapes.Gettop(ball)
Program.Delay(500)
EndSub

Sub calc
For step1=0 To 1 'No=1
For step2=0 To 2 'No=2
If step1=0 Then
step2=2
EndIf
For step3=0 To 2 'No=3
If step2=0 Then
step3=2
EndIf
For step4=0 To 2 'No=4
If step3=0 Then
step4=2
EndIf
For step5=0 To 2 'No=5
If step4=0 Then
step5=2
EndIf
For step6=0 To 2 'No=6
If step5=0 Then
step6=2
EndIf
For step7=0 To 2 'No=7
If step6=0 Then
step7=2
EndIf
For step8=0 To 2 'No=8
If step7=0 Then
step8=2
EndIf
For step9=0 To 2 'No=9
If step8=0 Then
step9=2
EndIf
For step10=0 To 2 'No=10
If step9=0 Then
step10=2
EndIf
For step11=0 To 2 'No=11
If step10=0 Then
step11=2
EndIf
For step12=1 To 2 'No=12
If step11=0 Then
step12=2
EndIf
Total=step1+step2+step3+step4+step5+step6+ step7+step8+step9+ step10+step11+step12
If Total=12 Then
NN=NN+1
t14=text.Append(text.Append(step1,step2),text.Append(step3,step4))
t58=text.Append(text.Append(step5,step6),text.Append(step7,step8))
t912=text.Append(text.Append(step9,step10),text.Append(step11,step12))
t112= text.Append(Text.Append(t14,t58),t912)
' TextWindow.WriteLine(NN+ " : "+ t112)
Move_Ball()
EndIf
EndFor
EndFor
EndFor
EndFor
EndFor
EndFor
EndFor
EndFor
EndFor
EndFor
EndFor
EndFor
EndSub

Sub gui
GraphicsWindow.Width=800
GraphicsWindow.Height=600
GraphicsWindow.BackgroundColor="lightcyan"
GraphicsWindow.BrushColor="Darkgreen"
GraphicsWindow.PenColor="lightcyan"
For j=1 To 12
For i=12 To j step -1
block[j][i]= Shapes.AddRectangle(40,40)
Shapes.Move(block[j][i],(j-1)*40+50,(i-1)*40+50)
EndFor
base=Shapes.AddRectangle(40*15,50)
Shapes.Move(base,50,50+40*12)
EndFor
GraphicsWindow.BrushColor="Red"
GraphicsWindow.PenColor="Red"
ball= Shapes.AddEllipse(25,25)
Shapes.Move(ball,50+5,50-25)
BXY="X="+ Shapes.GetLeft(ball)+";Y="+ Shapes.Gettop(ball)
delay="1=200;2=80;3=10"
GraphicsWindow.BrushColor="Yellow"
GraphicsWindow.FontSize=20
mes= Shapes.AddText(" ")
Shapes.Move(mes,50+20,50+20+40*12)
EndSub