Capacitación básica en Computación
Excellent program written by NaoChanOn
Challenge of the month July 2013 // Walking man by NaochanON
Program Code:
Shapes_Init()
Shapes_Add()
While (pos<1100)
dx=6
dy=2
MM=MM+5
walking()
If -30<MM And MM<30 Then
NN=MM
ElseIf 30<=MM and MM<90 Then
NN=60-MM
Elseif MM=90 then
MM=-30
EndIf
Program.Delay(200)
endwhile
Sub armlegmoving
rad=math.GetRadians(NN)
‘————————————– Arm & Hand —————————————————————————————
ArmCP=”X=”+(shapes.GetLeft(shp[7]["obj"])+shp[7]["width"]/2)+”;Y=”+(shapes.Gettop(shp[7]["obj"]))
ArmDR= shp[5]["height"]/2
Shapes.Rotate(shp[8]["obj"],NN) ‘ Left arm // backward
Shapes.Move(shp[8]["obj"],ArmCP["X"]- ArmDR*Math.Sin(rad), ArmCP["Y"]+ArmDR*Math.cos(rad)-(shp[5]["y"]-shp[7]["y"]))
Shapes.Rotate(shp[9]["obj"],NN) ‘ Left hand // backward
Shapes.Move(shp[9]["obj"],ArmCP["X"]- 2*ArmDR*Math.Sin(rad), ArmCP["Y"]+2*ArmDR*Math.cos(rad)+shp[6]["height"]/2)
Shapes.Rotate(shp[5]["obj"],-NN) ’ Right arm // forward
Shapes.Move(shp[5]["obj"],ArmCP["X"]+ArmDR*Math.Sin(rad), ArmCP["Y"]+ArmDR*Math.cos(rad) -(shp[8]["y"]-shp[7]["y"]) )
Shapes.Rotate(shp[6]["obj"],-NN) ‘ Right hand// forward
Shapes.Move(shp[6]["obj"],ArmCP["X"]+ 2*ArmDR*Math.Sin(rad), ArmCP["Y"]+2*ArmDR*Math.cos(rad)+shp[9]["height"]/2)
‘————————————– Leg & Foot ————————————————————————————— —————-
LegCP=”X=”+(shapes.GetLeft(shp[7]["obj"])+shp[7]["width"]/2-5)+”;Y=”+(shapes.Gettop(shp[7]["obj"]) +shp[7]["height"]-5) ‘ 5… adjustment
LegDR=shp[10]["height"]/2
Shapes.Rotate(shp[10]["obj"],NN) ’ Left leg // backward
Shapes.Move(shp[10]["obj"],LegCP["X"]- LegDR*Math.Sin(rad), LegCP["Y"])
Shapes.Rotate(shp[11]["obj"],NN) ‘ Left foot // backward
Shapes.Move(shp[11]["obj"],LegCP["X"]- 2*LegDR*Math.Sin(rad), LegCP["Y"]+2*LegDR*Math.cos(rad))
Shapes.Rotate(shp[12]["obj"],-NN) ‘ Right leg// forward
Shapes.Move(shp[12]["obj"],LegCP["X"]+ LegDR*Math.Sin(rad), LegCP["Y"])
Shapes.Rotate(shp[13]["obj"],-NN) ‘ Left foot // forward
Shapes.Move(shp[13]["obj"],LegCP["X"]+ 2*LegDR*Math.Sin(rad), LegCP["Y"]+2*LegDR*Math.cos(rad))
EndSub
Sub walking
For k=1 To Array.GetItemCount(shp)
Shapes.Move(shp[k]["obj"],Shapes.GetLeft(shp[k]["obj"])+dx,Shapes.Gettop(shp[k]["obj"])+dy)
endfor
pos=Shapes.GetLeft(shp[1]["obj"])
armlegmoving()
EndSub
Sub Shapes_Add
GraphicsWindow.BackgroundColor=”Lightcyan”
GraphicsWindow.Width=1200
GraphicsWindow.Height=700
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"])
ElseIf shp[i]["func"] = “tri” Then
shp[i]["obj"] = shapes.AddTriangle(shp[i]["x1"], shp[i]["y1"], shp[i]["x2"], shp[i]["y2"], shp[i]["x3"], shp[i]["y3"] )
ElseIf shp[i]["func"] = “line” Then
shp[i]["obj"] = shapes.AddLine(shp[i]["x1"], shp[i]["y1"], shp[i]["x2"], shp[i]["y2"])
EndIf
Shapes.Move(shp[i]["obj"], X0 + shp[i]["x"], Y0 + shp[i]["y"])
If shp[i]["angle"] <> 0 Then
Shapes.Rotate(shp[i]["obj"], shp[i]["angle"])
EndIf
EndFor
EndSub
Sub Shapes_Init
X0 = 10 ‘ x offset
Y0 = 50 ‘ y offset
shp[1] = “func=ell;x=42;y=0;width=34;height=45;bc=#EB9869;pc=#EB9869;pw=2;” ‘ face
shp[2] = “func=line;x=65;y=13;x1=0;y1=0;x2=8;y2=1;pc=#6A5ACD;pw=4;” ‘ Eye
shp[3] = “func=line;x=65;y=29;x1=0;y1=0;x2=8;y2=3;pc=#F80800;pw=2;” ’ mouse
shp[4] = “func=tri;x=74;y=17;x1=0;y1=0;x2=10;y2=8;x3=0;y3=12;angle=0;bc=#EB9869;pc=#EB9869;pw=1;” ‘nose
shp[5] = “func=rect;x=53;y=50;width=8;height=60;angle=0;bc=#6A5ACD;pc=#000000;pw=1;” ‘ Left arm
shp[6] = “func=ell;x=53;y=110;width=13;height=22;angle=0;bc=#EB9869;pc=#EB9869;pw=8;” ‘ Left hand
shp[7] = “func=ell;x=40;y=42;width=33;height=103;bc=#00AA00;pc=#00AA00;pw=2;” ‘ body
shp[8] = “func=rect;x=53;y=50;width=8;height=60;angle=0;bc=#00BB00;pc=#000000;pw=1;” ‘ Right arm
shp[9] = “func=ell;x=53;y=110;width=13;height=22;angle=0;bc=#EB9869;pc=#EB9869;pw=2;” ‘ Right hand
shp[10] = “func=rect;x=50;y=140;width=12;height=71;angle=0;bc=#6A5ACD;pc=#6A5ACD;pw=2;” ‘ left Leg
shp[11] = “func=ell;x=50;y=209;width=33;height=13;angle=0;bc=#BED3CA;pc=#414C3E;pw=2;” ‘ left foot
shp[12] = “func=rect;x=50;y=140;width=12;height=71;angle=0;bc=#00AA00;pc=#6A5ACD;pw=2;” ‘ Right Leg
shp[13] = “func=ell;x=50;y=209;width=33;height=13;angle=0;bc=#1AD3CA;pc=#414C3E;pw=2;” ‘ Right foot
EndSub
%d bloggers like this:
No comments:
Post a Comment