# simple escape algorithm: enemy escapes when hero approches

I need some clues on a "escape" algorithm. My scene a 2D rectangle (0,0,1000,1000)

I have enemy sprites on this scene. They are immobile until distance from hero <100. If distance<100, enemy tries to escape from here, so hero tries to chase it.

When distance>100, enemy has escaped and becomes immobile again. The rule is of course that enemy cannot go outside the scene. And a enemy cannot overflow enemy bonus.

Any clues ? Regards

• What is bonus? and what do you mean by a bonus cannot overflow another bonus? Can no two bonuses be next to each other? Also, does the 'bonus' have a speed? – Luis Estrada Dec 29 '12 at 0:43
• bonus = enemy sprite you try to catch – yarek Dec 29 '12 at 2:01
• What's the problem? This seems like a pretty simple and straight-forward set of rules. Is this a "teach me to program" question? (I mean, are you asking for someone to explain "if/else" conditionals to you? Or what?) – Trevor Powell Dec 29 '12 at 2:18
• I still do not understand what enemy bonus shall be. Neither do I understand what clues you need? Maybe something like: Calculate the direction to escape? – Aufziehvogel Dec 29 '12 at 9:42
• infact a bonus is an enemy that you need to catch – yarek Dec 29 '12 at 14:16