' 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