Microsoft Small Basic

Program Listing:
Embed this in your website
' Challenge of the month August 2012 Animal shapes naochanON
' Whale sharks


sharkdata()
makeshape()
For i=1 to 3
  reposition()
endfor

While "true"
  For i=1 To 3
    If Shapes.GetLeft(stri[i][14])+200*i<-50 Then
      reposition()
    EndIf
  EndFor
  move()
  Program.Delay(80)
endwhile

Sub reposition
  x0=1000+300*i
  y1=shapes.GetTop(stri[i][2])
  y0=math.GetRandomNumber(325)*(325-y1)/math.abs(325-y1)
  '-------------------------- body --------------------------
  For j=1 To 16
    Shapes.Move(stri[i][j],shapes.GetLeft(stri[i][j])+x0,shapes.GetTop(stri[i][j])+y0)
  endfor
  '-------------------------- mouse Eyes --------------------------
  For k=1 To 5
    Shapes.Move(sEl[i][k],shapes.GetLeft(sEl[i][k])+x0,shapes.GetTop(sEl[i][k])+y0)
  endfor
  For L=1 To 35
    Shapes.Move(sdEl[i][L],shapes.GetLeft(sdEl[i][L])+x0,shapes.GetTop(sdEl[i][L])+y0)
  endfor
  GraphicsWindow.Show()
EndSub

Sub move
  For i=1 To 3
    dx=math.GetRandomNumber(8)-2
    dy=(math.GetRandomNumber(8)-4)
    Op=(3+math.GetRandomNumber(2))/6
    dy=dy/10
    '-------------------------- body --------------------------
    For j=1 To 16
      Shapes.Move(stri[i][j],Shapes.GetLeft(stri[i][j])-dx,Shapes.Gettop(stri[i][j])+dy)
    endfor
    For j=10 To 14
      Shapes.rotate(stri[i][j],-op*6)   ' moving tail
    EndFor
    '-------------------------- mouse Eyes --------------------------
    For k=1 To 5
      Shapes.Move(sEl[i][k],Shapes.GetLeft(sEl[i][k])-dx,Shapes.Gettop(sEl[i][k])+dy)
    endfor
    Shapes.Zoom(sEl[i][3],1,op)  ' moving mouth
    For L=1 To 35
      Shapes.Move(sdEl[i][L],Shapes.GetLeft(sdEl[i][L])-dx,Shapes.Gettop(sdEl[i][L])+dy)
    endfor
  EndFor

EndSub

Sub sharkdata
  trx[1]="1=6;2=24.5;3=5.3"       ' gray
  try[1]="1=4;2=6;3=4.8"
  trx[2]="1=0.8;2=6;3=0.2"       ' Navy
  try[2]="1=0;2=4;3=2"
  trx[3]="1=0.8;2=8.5;3=6"
  try[3]="1=0;2=0.8;3=4"
  trx[4]="1=0.9;2=6;3=5.3"       '
  try[4]="1=2;2=4;3=4.8"
  trx[5]="1=8.5;2=30.6;3=6"       '
  try[5]="1=0.8;2=6.5;3=4"
  trx[6]="1=15.3;2=21.3;3=20"
  try[6]="1=2.4;2=0.3;3=3.6"
  trx[7]="1=17;2=20;3=20.2"
  try[7]="1=5;2=5.3;3=7.2"
  trx[8]="1=23.5;2=25;3=25.6"
  try[8]="1=4.4;2=3.8;3=5"
  trx[9]="1=22.2;2=24.2;3=24.5"
  try[9]="1=5.6;2=5.8;3=6.8"
  trx[10]="1=24.2;2=31.4;3=31.2"
  try[10]="1=5.8;2=6.5;3=8"
  trx[11]="1=27.6;2=31.8;3=31.2"
  try[11]="1=5.9;2=3;3=6.5"
  trx[12]="1=31.8;2=36;3=31.2"
  try[12]="1=3;2=1.5;3=6.5"
  trx[13]="1=28.2;2=31.2;3=30.2"
  try[13]="1=7;2=8;3=10.2"
  trx[14]="1=31.2;2=32.3;3=30.2"
  try[14]="1=8;2=10.8;3=10.2"
  trx[15]="1=9;2=12.5;3=11.8"
  try[15]="1=3.5;2=3.6;3=5.3"
  trx[16]="1=12.5;2=17;3=11.8"
  try[16]="1=3.6;2=6.8;3=5.3"
  W="1=0.8;2=0.8;3=5;4=0.5;5=0.8"
  H="1=2;2=2;3=0.8;4=0.5;5=0.8"
  ELx="1=0;2=5;3=0.5;4=0.6;5=5.3"
  ELy="1=0;2=2.3;3=0.5;4=0;5=3"
  dotx= "1=3.5;2=5.3;3=5.5;4=6.8;5=8;6=8;7=8.8;8=9.5;9=10;10=10.2;11=10.8;12=11.5;13=12.5;14=13.2;15=14.2;16=14.6;17=15.6;18=15.8;19=16.5;20=16.8;"
  dotx=dotx+"21=17.5;22=18.2;23=18.5;24=19.2;25=19.6;26=20.3;27=20.7;28=21.5;29=22.6;30=23.1;31=24.6;32=25.6;33=26.5;34=28.5;35=30.2"
  doty= "1=0.8;2=1;3=2;4=1.5;5=1.2;6=3;7=1.8;8=2.8;9=1.2;10=1.6;11=3.5;12=2.4;13=3.6;14=2.6;15=3.2;16=4.5;17=2.4;18=4;19=4.8;20=3.4;"
  doty=doty+"21=4;22=4.8;23=3.2;24=5;25=4.1;26=4;27=4.5;28=5;29=4.5;30=5;31=5.4;32=5.6;33=5.4;34=6.3;35=6.3"
endsub

Sub makeshape
  GraphicsWindow.Title=" Moving whale sharks ..... "
  GraphicsWindow.Width=1200
  GraphicsWindow.Height=650
  GraphicsWindow.Top=20
  GraphicsWindow.Left=50
  GraphicsWindow.BackgroundColor="lightcyan"
  GraphicsWindow.Hide()
  For i=3 To 1 Step -1
    '-------------------------- body --------------------------
    GraphicsWindow.BrushColor="gray"
    GraphicsWindow.penColor="gray"
    ZM=5*i
    stri[i][1]=Shapes.AddTriangle(trx[1][1]*ZM,try[1][1]*ZM,trx[1][2]*ZM,try[1][2]*ZM,trx[1][3]*ZM,try[1][3]*ZM)
    GraphicsWindow.BrushColor="Navy"
    GraphicsWindow.penColor="Navy"
    For j=2 To 16
      stri[i][j]=Shapes.AddTriangle(trx[j][1]*ZM,try[j][1]*ZM,trx[j][2]*ZM,try[j][2]*ZM,trx[j][3]*ZM,try[j][3]*ZM)
    endfor
    For k=1 To 2
      sEl[i][k]=Shapes.AddEllipse(W[k]*ZM,H[k]*ZM)
      Shapes.Move(sEl[i][k],ELx[k]*ZM,ELy[k]*ZM)
    endfor
    '-------------------------- mouse --------------------------
    GraphicsWindow.BrushColor="White"
    GraphicsWindow.penColor="white"
    sEl[i][3]=Shapes.AddEllipse(W[3]*ZM,H[3]*ZM)
    shapes.Move(sEl[i][3],ELx[3]*ZM,ELy[3]*ZM+H[3]*ZM)
    Shapes.Rotate(sEl[i][3],30)
    '-------------------------- Eyes --------------------------
    GraphicsWindow.BrushColor="Yellow"
    GraphicsWindow.penColor="Yellow"
    For K=4 To 5
      sEl[i][k]=Shapes.AddEllipse(W[k]*ZM,H[k]*ZM)
      Shapes.Move(sEl[i][k],ELx[k]*ZM,ELy[k]*ZM)
    endfor
    '-------------------------- dot mark --------------------------
    GraphicsWindow.BrushColor="White"
    GraphicsWindow.penColor="white"
    For L=1 To 35
      sdEl[i][L]=Shapes.AddEllipse(5,5)
      Shapes.Move(sdEl[i][L],dotx[L]*ZM,doty[L]*ZM)
    endfor
  EndFor

EndSub

Copyright (c) Microsoft Corporation. All rights reserved.