Press F1 to open the DB help where you can find about atanfull. It is a math function. It takes two prameters, an X and Y value. These values are the difference between the coordinates of point A and point B. So if your unit is standing at A and you want to move to B:
atanfull(B.x-A.x, B.y-A.y)
That will return an angle between the two points. To move your unit in that direction is simple trig:
unit.x = unit.x + sin(angle)*speed
unit.y = unit.y + cos(angle)*speed
Here's an example demonstrating that:
do
cls
if mouseclick() = 1
ax = mousex()
ay = mousey()
endif
if mouseclick() = 2
bx = mousex()
by = mousey()
endif
text ax, ay, "A"
text bx, by, "B"
a# = atanfull(bx-ax, by-ay)
dx = ax + sin(a#)*150
dy = ay + cos(a#)*150
line ax, ay, dx, dy
set cursor 0,0
print a#
loop
If you're curious about the math behind atanful, you can view my own function of it
here. Basically what the parameters of the function do is create a directional vector of point A to point B.
mousex() and
mousey() will get you the screen coordinates of your mouse cursor.
You can use this function to see if the mouse is within a certain area (a bounding box)
function mouseOverlap(x1, y1, x2, y2)
if mousex() > x1 and mousex() < x2 and mousey() > y1 and mousey() < y2 then exitfunction 1
endfunction 0
Here's the basic structure for selecting units:
rem if user left-clicked
if mouseclick() = 1
rem loop through all your units
for i = 1 to totalUnits
rem checks if mouse coordinates are within the boundaries
rem of a unit. (this code assumes units are 10 x 10)
if mouseOverlap(units(i).x,units(i).y, units(i).x+10,units(i).y+10) = 1
// unit was selected
endif
next i
endif