Thread: Damn move()
View Single Post
  #3  
Old 01-21-2007, 05:26 PM
Chompy Chompy is offline
¯\(º_o)/¯
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
Quote:
Originally Posted by Chandler View Post
HTML Code:
function onCreated()
{
  this.showCharacter();
  
  this.curPlayer = findPlayer("cHANDLER");
  this.onTimeout();
}
function onTimeout()
{
  temp.movex = this.curPlayer.x - x; // x needed to travel to player
  temp.movey = this.curPlayer.y - y; // y needed to travel to player
  dir = getdir(temp.movex, temp.movey);
  
  if (player.dir == 1) { this.desx = 1.7;   this.desy = 1;    }
  if (player.dir == 0) { this.desx = -1.7;  this.desy = 1;    }
  if (player.dir == 2) { this.desx = 1.7;   this.desy = -1.7; }
  if (player.dir == 3) { this.desx = -1.7;  this.desy = -1.7; }
 
  this.ani = "walk";
  move((temp.movex + this.desx), (temp.movey + this.desy), 1, 1);
}
function onMovementFinished()
{
  this.ani = "idle";
  this.onTimeout();
}
Mainly, you should focus on the "onMovementFinished()" function.
That's how I was testing it, however it wasn't finishing the movement. (Wasn't calling "onMovementFinished()")
You need to add 8 to the move options to trigger that.

And, for better, and smooth movement (time wise),
use this:

PHP Code:
dist = ( dx dy 2) ^ 0.5;
movedxdydist tilespersecondflags); 
__________________
Reply With Quote