It shouldn't be a problem to have two entities controlled by different players.
Here is an example code that should work (e.g. for a splitscreen game):
Code:
entity* player1;
entity* player2;
action player1_act
{
player1 = my;
//here comes the rest of your movement code for player 1
}
action player2_act
{
player2 = my;
//here comes the rest of your movement code for player2
}
Now you should be able to get the x-distance between both of them and store it into a var:
Code:
var distance;
//put this into a function:
distance = abs(player1.x - player2.x);
But you have to make sure that both entities exists and that their pointers are not zero.