I want an enemy to stay within a certain range from its initial starting point (say x=200,y=200) and its stays within 50pixels from this point how would I do this?
I've tried the distance comparable but don't really understand how it works, any help would be appreciated
thanks in advance
you can use some sprites as guides for your enemies, if they collide with them they will change their direction.
You arent really giving enough info. What behavior are your enemies using? Also, distance() will return the amount of pixels between object1 and object2 so you're on the right track.
Develop games in your browser. Powerful, performant & highly capable.
Enemies are place in the layout and its X and Y position are stored in instance variables on start of layout
they move via 8 Direction object
if the enemies X co or Y co are (lets say) more than 50 pixels away from their instance variable counterpart then the enemie would return to the instance variables location
This should be an easy thing to do but i can't figure how to do it