Microsoft Small Basic

Program Listing:
Embed this in your website
' 20140920 Running Man // shadow boxsing by NaochanON
div=20                                  ' divided number
ddx=8                                   ' moving speed
FT="True"
shapessetup()
shapes_add()
get_WH()
While  "True"
  Running()
endwhile

Sub Running
  If 1300<BTX Then
    ddx=-ddx                              ' walking speed // Left direction
    Y0= 300-Math.GetRandomNumber(200)
    FT="True"
  ElseIf btx<-200 then
    ddx=-ddx                              ' walking speed // Right direction
    Y0= 400-Math.GetRandomNumber(200)
    FT="True"
  EndIf
  '-----------------------------------------------------------------------------------------------------------------------------------------------
  If ddx>0 Then                           ' Running to Right
    Rot["Post"]="1=5;2=80;3=50;4=30;5=50;6=80;7=20;8=5;9=-80;10=-180;11=-170;12=-60;13=-30;14=-120"
    moving()
    Program.Delay(10)
    Rot["Post"]="1=5;2=-80;3=-180;4=-170;5=-60;6=-30;7=-120;8=5;9=80;10=40;11=30;12=50;13=80;14=20"
    moving()
    If FT="True" And  BTX>400 Then
      FightingPause()
    EndIf
  Else                                    ' Running to Left
    Rot["Post"]="1=-5;2=-80;3=-50;4=-30;5=-50;6=-80;7=-20;8=-5;9=80;10=180;11=170;12=60;13=40;14=120"
    moving()
    Program.Delay(10)
    Rot["Post"]="1=-5;2=80;3=180;4=170;5=60;6=40;7=120;8=-5;9=-80;10=-50;11=-30;12=-50;13=-80;14=-20"
    moving()
    If FT="True" And  BTX<650 Then
      FightingPause()
    EndIf
  EndIf
EndSub

Sub FightingPause
  div=6
  If ddx>0 Then
    Rot["Post"]="1=15;2=-75;3=-190;4=-190;5=30;6=50;7=-30;8=10;9=-0;10=-160;11=-160;12=-30;13=0;14=-90"  ' Fighting pause
  Else
    Rot["Post"]="1=-5;2=75;3=190;4=190;5=-30;6=-50;7=30;8=-10;9=0;10=160;11=160;12=30;13=0;14=90"       ' defensing pause
  EndIf
  moving()
  Program.Delay(100)
  Jab()
  Jab()
  Program.Delay(100)
  div=20
EndSub

Sub Jab
  If ddx>0 Then
    Rot["Post"]="1=15;2=-75;3=-190;4=-190;5=30;6=50;7=-30;8=10;9=-90;10=-90;11=-90;12=-30;13=0;14=-90"  ' Punching
    moving()
    Rot["Post"]="1=15;2=-75;3=-190;4=-190;5=30;6=50;7=-30;8=10;9=-0;10=-160;11=-160;12=-30;13=0;14=-90"  ' Fighting pause
    moving()
  Else
    Rot["Post"]="1=-5;2=75;3=190;4=190;5=-30;6=-50;7=30;8=-10;9=90;10=90;11=90;12=30;13=0;14=90"        ' Punching
    moving()
    Rot["Post"]="1=-5;2=75;3=190;4=190;5=-30;6=-50;7=30;8=-10;9=0;10=160;11=160;12=30;13=0;14=90"       ' Fighting pause
    moving()
  EndIf
  FT="False"
  Program.Delay(50)
EndSub

Sub moving
  For j=0 To div
    Parts_Position()
    Program.Delay(10)
  endfor
  Rot["Pre"]=Rot["Post"]
EndSub

Sub Parts_Position
  For i=1 To 14
    sds[i]=Math.Sin(Math.GetRadians(rot["Pre"][i]+(rot["Post"][i]-rot["Pre"][i])*j/div))   ' sin value (rot["Post"][i]-rot["Pre"][i])*j/div)
    cds[i]=Math.cos(Math.GetRadians(rot["Pre"][i]+(rot["Post"][i]-rot["Pre"][i])*j/div) )  ' cosin value (rot["Post"][i]-rot["Pre"][i])*j/div)
    shapes.Rotate(shp[i]["obj"],rot["Pre"][i]+(rot["Post"][i]-rot["Pre"][i])*j/div)        ' rotate shapes
  EndFor
  BTX=Shapes.GetLeft(shp[8]["obj"])                               ' Body X-pos
  BTY=Shapes.GetTop(shp[8]["obj"])                                ' Body Y-Pos
  Shapes.Move(shp[8]["obj"],BTX+ddx*j/div, Y0)                    ' Body moved
  '---------------------------------------------------------------
  BTX=Shapes.GetLeft(shp[8]["obj"])                               ' Body X-pos
  BTY=Shapes.GetTop(shp[8]["obj"])                                ' Body Y-Pos
  SHx=BTX+(1-0.3)*LH[8]/2*sds[8]+LW[8]/2                          ' Sholder X-pos
  SHy=BTY-(1-0.3)*LH[8]/2*cds[8]+LH[8]/2                          ' Sholder X-pos
  Hpx=SHX +0.3*LH[8]/2*sds[8] -LH[8]*sds[8]                       ' Hip X-pos
  HpY=SHy -0.3*LH[8]/2*cds[8] +LH[8]*cds[8]                       ' Hip Y-pos
  '---------------------------------------------------------------
  Shapes.Move(shp[1]["obj"],SHx+(0.35*LH[8]/2+LH[1]/2)*sds[8]-LW[1]/2,SHY-(0.35*LH[8]/2+LH[1])*cds[8])  ' Head
  shapes.Rotate(shp[1]["obj"], Rot[1]*j/div)                      ' rotate Head
  '---------------------------------------------------------------
  SHP_N="2:5:9:12"
  SHHP["X"]="2="+(SHX)+";5="+(HPX)+";9="+(SHX)+";12="+(HPX)       ' X-position of No 2,5,9,12 shapes
  SHHP["Y"]="2="+(SHY)+";5="+(HPY)+";9="+(SHY)+";12="+(HPY)       ' Y-position of No 2,5,9,12 shapes
  Shapes.Move(dms,SHHP["X"][2]-5,SHHP["Y"][2]-5)                  ' move dumy circle to sholder position
  Shapes.Move(dmH,SHHP["X"][5]-5,SHHP["Y"][5]-5)                  ' move dumy circle to Hip position
  For N=2 To 12
    If Text.IsSubText(SHP_N,N)="True" Then                        ' N=2 or 5 or 9 or 12
      Shapes.Move(shp[N]["obj"], sHHP["X"][N]-sds[N]*LH[N]/2-LW[N]/2, SHHP["Y"][N]+cds[N]*LH[N]/2-LH[N]/2)             ' move shape[N] to rotated position
      Larm[N]="X="+(SHHP["X"][N]-sds[N]*LH[N])+";Y="+(SHHP["Y"][N]+cds[N]*LH[N])                                       ' length of arm [N](leg)
      Shapes.Move(shp[N+1]["obj"],Larm[N]["X"]-sds[N+1]*LH[N+1]/2-LW[N+1]/2,Larm[N]["Y"]+cds[N+1]*LH[N+1]/2-LH[N+1]/2) ' move shape[N+1] to rotated position
      Larm[N+1]="X="+(Larm[N]["X"]-sds[N+1]*LH[N+1])+";Y="+(Larm[N]["Y"]+cds[N+1]*LH[N+1])                             ' length of arm[N+1] (leg)
      Shapes.Move(shp[N+2]["obj"],Larm[N+1]["X"]-sds[N+2]*LH[N+2]/2-LW[N+2]/2,Larm[N+1]["Y"]-(1-cds[N+2])*LH[N+2]/2)   ' move shape[N+2] to rotated position
    EndIf
  EndFor
EndSub

Sub shapessetup
  GraphicsWindow.Width=1200
  GraphicsWindow.Height=700
  GraphicsWindow.DrawImage("C:\Windows\Web\Wallpaper\Landscapes\img12.jpg",0,0)
  GraphicsWindow.Title="Shadow Boxing "
  shp[1] = "func=ell;x=14;y=0;width=31;height=50;bc=#0C9886;pc=#000000;pw=2;"     ' Head
  shp[2] = "func=rect;x=25;y=77;width=12;height=55;bc=#0C9886;pc=#000000;pw=2;"   ' Left arm-1
  shp[3] = "func=rect;x=25;y=132;width=12;height=45;bc=#0C9886;pc=#000000;pw=2;"  ' Left arm-2
  shp[4] = "func=ell;x=25;y=177;width=13;height=29;bc=#0C9886;pc=#000000;pw=2;"   ' Left arm-3
  shp[5] = "func=rect;x=20;y=173;width=12;height=55;bc=#0C9886;pc=#000000;pw=2;"  ' Left leg-1
  shp[6] = "func=rect;x=20;y=223;width=12;height=50;bc=#0C9886;pc=#000000;pw=2;"  ' Left leg-2
  shp[7] = "func=ell;x=20;y=270;width=10;height=36;bc=#0C9886;pc=#000000;pw=2;"   ' Left leg-3
  shp[8] = "func=ell;x=11;y=50;width=34;height=100;bc=#0C9886;pc=#000000;pw=2;"   ' Body
  shp[9] = "func=rect;x=25;y=77;width=12;height=55;bc=#0C9886;pc=#000000;pw=2;"   ' right arm-1
  shp[10] = "func=rect;x=25;y=132;width=12;height=45;bc=#0C9886;pc=#000000;pw=2;" ' right arm-2
  shp[11] = "func=ell;x=25;y=177;width=13;height=29;bc=#0C9886;pc=#000000;pw=2;"  ' right arm-3
  shp[12] = "func=rect;x=25;y=173;width=12;height=55;bc=#0C9886;pc=#000000;pw=2;" ' right leg-1
  shp[13] = "func=rect;x=25;y=223;width=11;height=50;bc=#0C9886;pc=#000000;pw=2;" ' right leg-2
  shp[14] = "func=ell;x=25;y=273;width=10;height=36;bc=#0C9886;pc=#000000;pw=2;"  ' right leg-3
EndSub

Sub Shapes_Add
  X0 = 0
  Y0 = 500
  For i = 1 To Array.GetItemCount(shp)
    GraphicsWindow.PenWidth = shp[i]["pw"]
    GraphicsWindow.PenColor = shp[i]["pc"]
    GraphicsWindow.BrushColor = shp[i]["bc"]
    If shp[i]["func"] = "rect" Then
      shp[i]["obj"] = shapes.AddRectangle(shp[i]["width"], shp[i]["height"])
    ElseIf shp[i]["func"] = "ell" Then
      shp[i]["obj"] = shapes.AddEllipse(shp[i]["width"], shp[i]["height"])
    EndIf
    Shapes.Move(shp[i]["obj"], X0 + shp[i]["x"], Y0 + shp[i]["y"])
  EndFor
  dmS=Shapes.AddEllipse(10,10)  ' sholder point
  dmH=Shapes.AddEllipse(10,10)  ' hip point
EndSub

Sub Get_WH
  For i=1 To 14
    LW[i]= shp[i]["width"]      ' width of shape (shp[i])
    LH[i]= shp[i]["height"]     ' height of shape (shp[i])
    rot["Pre"][i]=0             ' initial angles
  EndFor
EndSub

Copyright (c) Microsoft Corporation. All rights reserved.