Nice game I did level 6!
well then the most important part of the script is this:
[AS]this.diffx = (you._x-this._x);
this.diffy = (you._y-this._y);
this.distance = Math.sqrt((this.diffxthis.diffx)+(this.diffythis.diffy));
if (this.distance<this.sight) {
this.ang = Math.atan2(this.diffy, this.diffx);
}
[/AS]
basicaly what it does is check whether the player is at a certain distance from the bady. it does this using the pythagorian theorum. you find the horizintal and vertical distance between the mc’s and then use the formul c^2 = a^2 + b^2 which is equal to c = sqrt(a^2 + b^2) in action script that would be :
[AS]this.distance = Math.sqrt((this.diffxthis.diffx)+(this.diffythis.diffy));[/AS]
when the distance is less than a certain distance, in this case the enemy’s site, then use the trigonometric function to find the angle at which the character is. if the character is out of range, then use the random angle. finally, move the bady in that angle specified using the ‘moveBady’ function with the angle as a parameter… i hope that was a half decent explanation… good luck