you need to find the distance between the player and enemy with the distance formula:
then make some artificial intelligence for when the player is far enough away.
square root((x2-x1)^2 + (y2-y1)^2)if this comes out to be less than a certian distance, make the eniemy attack
then make some artificial intelligence for when the player is far enough away.