'By Leonel Morales Diaz - leonel@ingenieriasimple.com
'Move the runner left or right with the arrow keys.
'Step into stones to avoid falling.
'This game is a starting point. Many more can be done using the same principles.
For i = 1 To 4
Tierra[i] = Shapes.AddImage(Terron)
Shapes.HideShape(Tierra[i])
Shapes.Move(Tierra[i],Math.GetRandomNumber(GraphicsWindow.Width),GraphicsWindow.Height*(0.25*i))
Shapes.ShowShape(Tierra[i])
EndFor
Sub CaeCorredor
DeltaXCo = 15
DeltaYCo = 3
DeltaYTrra = 10
CurXCo = Shapes.GetLeft(CorredorSh[Corredor][1])
CurYCo = Shapes.GetTop(CorredorSh[Corredor][1])
For i = 1 To 4
CurXTrra = Shapes.GetLeft(Tierra[i])
CurYTrra = Shapes.GetTop(Tierra[i])
'GraphicsWindow.DrawEllipse(CurXTrra+7,CurYTrra,52,5)
'GraphicsWindow.DrawEllipse(CurXCo+25,CurYCo+60,35,5)
If Math.Abs(CurXTrra - CurXCo - 18) < 52 And Math.Abs(CurYTrra - CurYCo - 60) < 15 Then
DeltaYCo = - DeltaYTrra
EndIf
If CurYTrra <= -50 Then
Shapes.HideShape(Tierra[i])
Shapes.Move(Tierra[i],Math.GetRandomNumber(GraphicsWindow.Width),GraphicsWindow.Height)
Shapes.ShowShape(Tierra[i])
EndIf
EndFor
Shapes.HideShape(CorredorSh[Corredor][1])
Shapes.HideShape(CorredorSh[Corredor][-1])
Corredor = Math.Remainder(Corredor,6) + 1
Shapes.ShowShape(CorredorSh[Corredor][CorredorDir])
For i = 1 To 6
If i = Corredor Then
Shapes.Animate(CorredorSh[i][1],CurXCo + DeltaXCo*CorredorDir,CurYCo + DeltaYCo,150)
Shapes.Animate(CorredorSh[i][-1],CurXCo + DeltaXCo*CorredorDir,CurYCo + DeltaYCo,150)
Else
Shapes.Move(CorredorSh[i][1],CurXCo + DeltaXCo*CorredorDir,CurYCo + DeltaYCo)
Shapes.Move(CorredorSh[i][-1],CurXCo + DeltaXCo*CorredorDir,CurYCo + DeltaYCo)
EndIf
EndFor
For i = 1 To 4
CurXTrra = Shapes.GetLeft(Tierra[i])
CurYTrra = Shapes.GetTop(Tierra[i])
Shapes.Animate(Tierra[i],CurXTrra,CurYTrra-DeltaYTrra,150)
EndFor
EndSub
Sub CambiaDireccionCorredor
If GraphicsWindow.LastKey = "Left" Then
CorredorDir = -1
ElseIf GraphicsWindow.LastKey = "Right" Then
CorredorDir = 1
EndIf
EndSub