I'd like to make something like a fight in my game, but where the enemy and the player would be moving and they would be attacable from a specific (or smaller)distance between them (it would be with a longsword), but I don't know how to define the distance. Please help.
Simplest way is to calculate it like this (don't need to square root it unless you really need that):
xdiff = cEgo.x - cEnemy.x;
ydiff = cEgo.y - cEnemy.y;
dif = xdiff*xdiff + ydiff*ydiff;