What's wrong with using maths? Also, the physics commands aren't a magic cure that sorts all these problems out. To be honest, if you don't know how to do this using maths then you're probably not going to be able to do this using the physics commands.
Anyway, here are two examples:
This one use basic trigonometry and Pythagoras to determine the direction and speed of the sprite moving toward the cursor.
//set window properties
SetWindowSize( 1024, 768, 0 )
SetVirtualResolution( 1024, 768 )
// play around with these two variables to affect the move speed and acceleration
factor# = 0.1
max_move# = 50.0
// starting position of the sprite
pos_x# = 1024/2
pos_y# = 768/2
// create and position the sprite
spr = CreateSprite(0)
SetSpriteSize(spr,20,20)
SetSpritePositionByOffset(spr,pos_x#,pos_y#)
do
print("press and hold and left mouse button")
print("move the cursor so the sprite follows")
if GetPointerState() = 1
// get the point position
pointer_x# = getPointerX()
pointer_y# = getPointerY()
// determine the difference between the sprite position and the pointer
diff_x# = pointer_x# - pos_x#
diff_y# = pos_y# - pointer_y#
// calculate distance and angle between the cursor and the sprite
distance# = sqrt(diff_x#^2+diff_y#^2)
angle# = atanfull(diff_x#,diff_y#)
// determine how fast to move the sprite
// this is based on the distance between the sprite and the cursor
// the closer they are the slower the sprite moves
move# = distance#*factor#
// set a maximum speed for the sprite to move
if move# > max_move#
move# = max_move#
endif
// determine the x and y movement
move_x# = move#*sin(angle#)
move_y# = move#*cos(angle#)
// calculate the new position and position the sprite
pos_x# = pos_x# + move_x#
pos_y# = pos_y# + move_y#
SetSpritePositionByOffset(spr,pos_x#,pos_y#)
endif
sync()
loop
This second one uses a simplified version of newton's laws of motion . I use this approach a lot for movement as you can add a bit of a bounce to the movement. Set the damping# value to 0.2 you'll see what I mean.
// set window properties
SetWindowSize( 1024, 768, 0 )
SetVirtualResolution( 1024, 768 )
// play around with these two variables to affect the move speed and acceleration
stiffness# = 0.05
damping# = .5
// starting position of the sprite
pos_x# = 1024/2
pos_y# = 768/2
// create and position the sprite
spr = CreateSprite(0)
SetSpriteSize(spr,20,20)
SetSpritePositionByOffset(spr,pos_x#,pos_y#)
do
print("press and hold and left mouse button")
print("move the cursor so the sprite follows")
if GetPointerState() = 1
// get the point position
pointer_x = getPointerX()
pointer_y = getPointerY()
// determine the acceleration of the sprite
// this is based on the distance between the cursor and the sprite
// and the current velocity of the sprite
acc_x# = stiffness# *(pointer_x - pos_x#) - damping#*vel_x#
acc_y# = stiffness# *(pointer_y - pos_y#) - damping#*vel_y#
// calculate the velocity of the sprite
vel_x# = vel_x# + acc_x#
vel_y# = vel_y# + acc_y#
// calculate the new position and position the sprite
pos_x# = pos_x# + vel_x#
pos_y# = pos_y# + vel_y#
SetSpritePositionByOffset(spr,pos_x#,pos_y#)
endif
Sync()
loop
I hope these give you some ideas.