This code makes no sense.. Even with only 1 enemy instance it will not work correctly. When you are near the enemy, the player will start moving by itself, running away up/down from the enemy. If there are multiple enemies on the layout, I can't even imagine what it will do...
Please explain how the player should be controlled (keyboard, on-screen virtual joystick etc), and how do you want it to be animated. Why are you comparing player position with enemy position? Should the animation change somehow when there is an enemy nearby?
Also, check out these tutorials: