'-----------------------
' Initialize
'-----------------------
GraphicsWindow.Title = "Having fun with Turtle"
GraphicsWindow.BrushColor = GraphicsWindow.GetColorFromRGB(127,127,127)
GraphicsWindow.FontName="arial"
GraphicsWindow.FontSize=30
GraphicsWindow.Fontbold="true"
GraphicsWindow.DrawText(0, 0, "Move mouse, then the turtle will follow you.")
moveHorizontal = 5
moveVerticle = 5
Sub onTimerTick
' Get the new X position of the turtle
If (mouseX < turtleX) Then
If (turtleX - mouseX < 5) Then
turtleX = mouseX
Else
turtleX = turtleX - moveHorizontal
EndIf
ElseIf (mouseX > turtleX) Then
If (mouseX - turtleX < 5) Then
turtleX = mouseX
Else
turtleX = turtleX + moveHorizontal
EndIf
EndIf
' Get the new Y position of the turtle
If (mouseY < turtleY) Then
If (turtleY - mouseY < 5) Then
turtleY = mouseY
Else
turtleY = turtleY - moveVerticle
EndIf
ElseIf (mouseY > turtleY) Then
If (mouseY - turtleY < 5) Then
turtleY = mouseY
Else
turtleY = turtleY + moveVerticle
EndIf
EndIf
' Move the turtle to new position
Turtle.X = turtleX
Turtle.Y = turtleY
EndSub
Sub onMouseMove
mouseX = GraphicsWindow.MouseX
mouseY = GraphicsWindow.MouseY
EndSub