Microsoft Small Basic

Program Listing: VSH227
' Challenge of the Month - October 2017 -- Graphics Challenge -- by NaochanON
GraphicsWindow.BackgroundColor="#D8E698"
GraphicsWindow.Width=1200
GraphicsWindow.Height=650
init()
add_shapes()
dx=5 ' moving length X-direction
ds=dx*360/shape[12]["wd"]/math.pi ' rotating angle
dy=0
While "True"
for i=1 To Array.GetItemCount(shape)
Shapes.Move(shp[SName][i],Shapes.GetLeft(shp[SName][i])+dx,Shapes.Gettop(shp[SName][i])+dy)
If i>19 then
angle[i]=angle[i]+ds
shapes.Rotate(shp[SName][i],angle[i])
endif
EndFor
GraphicsWindow.Title=Shapes.GetLeft(shp[SName][8])
If (math.abs(300-Shapes.GetLeft(shp[SName][8]))<25) Or (math.abs(650-Shapes.GetLeft(shp[SName][8]))<25) Or (math.abs(900-Shapes.GetLeft(shp[SName][8]))<25) Then
NN=NN+1
Shapes.Move(smoke[NN],Shapes.GetLeft(shp[SName][8]),Shapes.GetTop(shp[SName][8]))
EndIf
For k=1 To NN
Shapes.Move(smoke[k],Shapes.GetLeft(smoke[k])-dx-(15-k)/3*dx/math.Abs(dx),Shapes.Gettop(smoke[k])-9)
shapes.Zoom(smoke[k],(NN-k)/2,(NN-k)/3)
EndFor
If Shapes.Gettop(smoke[NN])<-30 Then
For k=1 to NN
Shapes.Move(smoke[k],-500,-500)
shapes.Zoom(smoke[k],1,1)
endfor
endif
If (dx>0 and Shapes.GetLeft(shp[SName][16])>1250) or (dx<0 and Shapes.GetLeft(shp[SName][16])<-50) Then
NN=0
dx=-dx
ds=dx*360/shape[12]["wd"]/math.pi ' rotating angle
pm=(325- shapes.GetTop(shp[SName][16]))/Math.Abs(325- shapes.GetTop(shp[SName][16]))
dy=pm*math.GetRandomNumber(325)
return()
EndIf
dy=0
Program.Delay(100)
endwhile


Sub return
For j=1 To Array.GetItemCount(shape)
if dx<0 then
Shapes.Move(shp[SName][j],Shapes.GetLeft(shp[SName][j])-2*shape[j]["x"]-shape[j]["wd"]+dL,Shapes.Gettop(shp[SName][j])+dy)
Else
Shapes.Move(shp[SName][j],Shapes.GetLeft(shp[SName][j])+2*shape[j]["x"]+shape[j]["wd"]-dL,Shapes.Gettop(shp[SName][j])+dy)
EndIf
EndFor
EndSub

Sub add_shapes
SName="train"
ss=scale[1]
for i=1 To Array.GetItemCount(shape)
GraphicsWindow.PenWidth = shape[i]["pw"]
GraphicsWindow.BrushColor = shape[i]["bc"]
GraphicsWindow.penColor = shape[i]["pc"]
If shape[i]["fn"]="el" Then
shp[SName][i] = Shapes.AddEllipse(shape[i]["wd"]*ss, shape[i]["ht"]*ss)
ElseIf shape[i]["fn"]="rec" Then
shp[SName][i] = Shapes.AddRectangle(shape[i]["wd"]*ss, shape[i]["ht"]*ss)
EndIf
Shapes.Animate(shp[SName][i], shape[i]["x"]*ss+shX[1], shape[i]["y"]*ss+shY[1], 500)
shapes.Rotate(shp[SName][i],shape[i]["deg"])
angle[i]=shape[i]["deg"]
EndFor
EndSub

Sub init
scale[1]=1
shX[1]=100
shy[1]=100

Shape[1]="fn=rec;x=120;y=40;wd=120;ht=24;bc=#EA5506;pc=#EA5506;pw=0"
Shape[2]="fn=rec;x=120;y=64;wd=120;ht=24;bc=#D7003A;pc=#D7003A;pw=0"
Shape[3]="fn=rec;x=40;y=16;wd=86;ht=74;bc=#E95464;pc=#E95464;pw=0"
Shape[4]="fn=rec;x=58;y=22;wd=45;ht=34;bc=#EAF4FC;pc=#17184B;pw=2"
Shape[5]="fn=rec;x=14;y=78;wd=22;ht=14;bc=#726D40;pc=#726D40;pw=0"
Shape[6]="fn=rec;x=32;y=0;wd=98;ht=16;bc=#89C3EB;pc=#88CB7F;pw=3"
Shape[7]="fn=rec;x=150;y=18;wd=16;ht=24;bc=#89C3EB;pc=#89C3EB;pw=0"
Shape[8]="fn=rec;x=186;y=12;wd=22;ht=30;bc=#89C3EB;pc=#89C3EB;pw=0"
Shape[9]="fn=rec;x=146;y=12;wd=24;ht=6;bc=#88CB7F;pc=#88CB7F;pw=3"
Shape[10]="fn=rec;x=182;y=6;wd=30;ht=6;bc=#88CB7F;pc=#88CB7F;pw=3"
Shape[11]="fn=el;x=230;y=40;wd=22;ht=48;bc=#FEF263;pc=#007B43;pw=3"
Shape[12]="fn=el;x=22;y=68;wd=64;ht=64;bc=#EB6EA5;pc=#A59564;pw=8"
Shape[13]="fn=el;x=88;y=68;wd=64;ht=64;bc=#EB6EA5;pc=#A59564;pw=8"
Shape[14]="fn=el;x=154;y=86;wd=46;ht=46;bc=#EB6EA5;pc=#A59564;pw=6"
Shape[15]="fn=el;x=202;y=86;wd=46;ht=46;bc=#EB6EA5;pc=#A59564;pw=6"
Shape[16]="fn=el;x=0;y=66;wd=18;ht=40;bc=#E60033;pc=#E60033;pw=0"
Shape[17]="fn=el;x=80;y=22;wd=10;ht=16;bc=#17184B;pc=#17184B;pw=0"
Shape[18]="fn=el;x=77;y=38;wd=14;ht=19;bc=#17184B;pc=#17184B;pw=0"
Shape[19]="fn=rec;x=85;y=42;wd=14;ht=4;bc=#17184B;pc=#17184B;pw=0"
Shape[20]="fn=rec;x=52;y=76;wd=4;ht=48;bc=#007B43;pc=#007B43;pw=0"
Shape[21]="fn=rec;x=52;y=76;wd=4;ht=48;bc=#007B43;pc=#007B43;pw=0;deg=90"
Shape[22]="fn=rec;x=118;y=76;wd=4;ht=48;bc=#007B43;pc=#007B43;pw=0"
Shape[23]="fn=rec;x=118;y=76;wd=4;ht=48;bc=#007B43;pc=#007B43;pw=0;deg=90"
Shape[24]="fn=rec;x=176;y=90;wd=4;ht=38;bc=#007B43;pc=#007B43;pw=0"
Shape[25]="fn=rec;x=176;y=90;wd=4;ht=38;bc=#007B43;pc=#007B43;pw=0;deg=90"
Shape[26]="fn=rec;x=224;y=90;wd=4;ht=38;bc=#007B43;pc=#007B43;pw=0"
Shape[27]="fn=rec;x=224;y=90;wd=4;ht=38;bc=#007B43;pc=#007B43;pw=0;deg=90"
dL= shape[11]["x"]-shape[16]["x"]+100 ' mirror point

GraphicsWindow.BrushColor="#949495"
GraphicsWindow.PenColor="#727171"
For i= 1 To 40
smoke[i]= Shapes.AddEllipse(18,12)
Shapes.Move(smoke[i],-100,-100)
EndFor
EndSub