Microsoft Small Basic

Program Listing: XXS713
'challenge E.K. V 1.0
'jalpc January 2015
'image canstock6287653.jpg property of Pappa Lapub
'
'Silverlight ?
color = GraphicsWindow.GetPixel(0, 0)
If Text.GetLength(color) > 7 Then
silverlight = "True"
Else
silverlight = "False"
EndIf
'
GraphicsWindow.Show()
GraphicsWindow.Hide()
data_()
form_()
graphics_()
moveRamp_()
GraphicsWindow.Show()
'
While "True"
Program.Delay(1000)
jump_()
init_()
EndWhile
'
Sub form_
GraphicsWindow.Width = pgW-5
GraphicsWindow.Height = pgH-5
GraphicsWindow.Top=40
GraphicsWindow.Left=40
GraphicsWindow.CanResize="False"
GraphicsWindow.Title="CHALLENGE E.K. V1.0"
EndSub
'
Sub graphics_
' rampa para saltar
GraphicsWindow.BrushColor="Gray"
GraphicsWindow.PenColor="Gray"
r_w=longRamp
r_h=4
r_x =ox-r_w
r_y =oy-r_h/2
r_rx=r_w/2 'separacion del centro de rotacion en x
r_ry=0 'separacion del centro de rotacion en y
ramp = Shapes.AddRectangle(r_w,r_h)
Shapes.Move(ramp,r_x,r_y)
'
'suelo (ground)
GraphicsWindow.FillRectangle(0,pgH-60,pgW,4) 'suelo base
GraphicsWindow.FillRectangle(450,oy+20,148,53) 'suelo llegada
GraphicsWindow.FillTriangle(38,368,94,368,94,312) 'apoyo rampa
'
'bala (centro rotacion externo de la rampa) y traza de parabola
eKnievel = "http://l.thumbs.canstockphoto.com/canstock6287653.jpg"
ball1 = Shapes.AddImage(eKnievel)
b1_w = ImageList.GetWidthOfImage(eKnievel)
b1_h = ImageList.GetHeightOfImage(eKnievel)
'============= ????????
If silverlight Then
difSilverX=70.5 ' es la mitad del ancho en local = 141 (en remoto vale 0 ??)
difSilverY=75 ' es la mitad del alto en local = 150 (en remoto vale 0 ??)
Else
difSilverX=0
difSilverY=0
EndIf
'==============
b1_x=ox-b1_w/2-difSilverX
b1_y=oy-b1_h/2-difSilverY
Shapes.Zoom(ball1, .2,.2)
Shapes.HideShape(ball1)
Shapes.Move(ball1,b1_x,b1_y)
Shapes.ShowShape(ball1)
EndSub
'
Sub moveRamp_
angleRamp=-angle
Shapes.Rotate(ramp,angleRamp)
rotateX=r_rx
rotateY=r_ry
rad = Math.GetRadians(angleRamp)
difX = rotateX*Math.Cos(rad) - rotateY*Math.Sin(rad)
difY = rotateX*Math.Sin(rad) + rotateY*Math.Cos(rad) '
x=r_x+ rotateX-difX
y=r_y+rotateY-difY '
Shapes.Move(ramp,x,y)
EndSub
'
Sub jump_
'color para traza de bala
GraphicsWindow.BrushColor="Gray"
GraphicsWindow.PenColor="Gray"
GraphicsWindow.PenWidth=1
alpha = Math.GetRadians(angle)
xpos = ox
ypos = oy
lap= 0.1
vi = 62
gravity = 9.81
time=0
lapDraw=0
stepDraw=2
itemPoint=0
While xpos <= pgW And ypos <= oy
lapDraw=lapDraw+1
time=time+lap
X=Vi*time * Math.Cos(alpha)
Y=Vi*time * Math.Sin(alpha) - gravity/2 * time*time
xpos = ox+X
ypos = oy-Y
If silverlight Then
Shapes.Move(ball1,xpos-b1_w/2-difSilverX,ypos-b1_h/2-difSilverY)
Else
Shapes.Move(ball1,xpos-b1_w/2,ypos-b1_h/2)
EndIf
'
'Rotacion moto
If itemPoint <= 36 Then
Shapes.Rotate(ball1,-itemPoint*10)
Else
Shapes.Rotate(ball1,0)
EndIf
'
If Math.Remainder(lapDraw,stepDraw)=0 Then
itemPoint=itemPoint+1
Shapes.Move(point[itemPoint],xpos-1,ypos-1)
Shapes.ShowShape(point[itemPoint])
EndIf
Program.Delay(50)
EndWhile
For num = 1 To itemPoint
Shapes.Zoom(point[num],3,3)
Program.Delay(20)
Shapes.Zoom(point[num],.3,.3)
Program.Delay(20)
Shapes.HideShape(point[num])
Shapes.Zoom(point[num],1,1)
EndFor
EndSub
'
Sub init_
Shapes.Move(ball1,b1_x,b1_y)
EndSub
'
Sub data_
pgW = 598
pgH = 428
ox=100 'origen x coordenada inicial
oy=300 'origen y coordenada inicial
longRamp=100 'largo rampa = radio Giro
angleInit=45 'angulo inicial de la bala
angle=angleInit 'angulo variable de la bala
'objetos traza trayectoria
For itemPoint = 1 To 100
Shapes.HideShape(point[itemPoint])
point[itemPoint]=Shapes.AddEllipse(3,3)
EndFor
EndSub