Bit of code to demonstrate:
SetWindowSize ( 1920, 1080, 1 )
SetVirtualResolution ( 1920, 1080 )
SetSyncRate ( 60, 1 )
type vector
x as float
y as float
endtype
start as vector
target as vector
target.x = 100
target.y = 1000
speed = 13.37
red = MakeColor ( 255, 0, 0 )
green = MakeColor ( 0, 255, 0 )
repeat
if GetRawMouseLeftReleased()
moving = 1
start.x = GetRawMouseX()
start.y = GetRawMouseY()
angle# = ATan2 ( ( target.y - start.y ), ( target.x - start.x ) )
endif
if moving
inc start.x, cos ( angle# ) * speed
inc start.y, sin ( angle# ) * speed
DrawBox ( start.x-10, start.y-10, start.x+10, start.y+10, green, green, green, green, 1 )
if ( target.x - start.x )^2 + ( target.y - start.y )^2 < 400
moving = 0
endif
endif
DrawBox ( target.x-10, target.y-10, target.x+10, target.y+10, red, red, red, red, 1 )
print ( "Click anywhere" )
sync()
until GetRawKeyPressed ( 27 )
end