home *** CD-ROM | disk | FTP | other *** search
- newx = _root.player._x;
- newy = _root.player._y;
- distx = int(getProperty(this, _X) - newx);
- disty = int(getProperty(this, _Y) - newy);
- if(0 < disty && 0 < distx)
- {
- if(Math.abs(distx) < Math.abs(disty / 2))
- {
- with(this.ghost)
- {
- gotoAndStop("u");
- }
- }
- else if(Math.abs(disty) < Math.abs(distx / 2))
- {
- with(this.ghost)
- {
- gotoAndStop("l");
- }
- }
- else
- {
- with(this.ghost)
- {
- gotoAndStop("ul");
- }
- }
- }
- if(disty < 0 && 0 < distx)
- {
- if(Math.abs(distx) < Math.abs(disty / 2))
- {
- with(this.ghost)
- {
- gotoAndStop("d");
- }
- }
- else if(Math.abs(disty) < Math.abs(distx / 2))
- {
- with(this.ghost)
- {
- gotoAndStop("l");
- }
- }
- else
- {
- with(this.ghost)
- {
- gotoAndStop("dl");
- }
- }
- }
- if(disty < 0 && distx < 0)
- {
- if(Math.abs(distx) < Math.abs(disty / 2))
- {
- with(this.ghost)
- {
- gotoAndStop("d");
- }
- }
- else if(Math.abs(disty) < Math.abs(distx / 2))
- {
- with(this.ghost)
- {
- gotoAndStop("r");
- }
- }
- else
- {
- with(this.ghost)
- {
- gotoAndStop("dr");
- }
- }
- }
- if(0 < disty && distx < 0)
- {
- if(Math.abs(disty) < Math.abs(distx / 2))
- {
- with(this.ghost)
- {
- gotoAndStop("r");
- }
- }
- else if(Math.abs(distx) < Math.abs(disty / 2))
- {
- with(this.ghost)
- {
- gotoAndStop("u");
- }
- }
- else
- {
- with(this.ghost)
- {
- gotoAndStop("ur");
- }
- }
- }
- z = distx * distx + disty * disty;
- hyp = Math.sqrt(z);
- speed = 4;
- distance = int(hyp / speed);
- movex = distx / distance;
- movey = disty / distance;
- if(0 >= distance)
- {
- gotoAndPlay(1);
- }
- else
- {
- setProperty(this, _X, getProperty(this, _X) - movex);
- setProperty(this, _Y, getProperty(this, _Y) - movey);
- distance -= 1;
- }
-