Exemple #1
0
        public MovableObject(double posX, double posY)
        {
            this.PosX = posX;
            this.PosY = posY;
            this.moveDestination = new Vector();

            lastMove = DateTime.Now;
            moveDuration = 0;
        }
Exemple #2
0
        public void Move(double x, double y)
        {
            Vector currPosition = Position;
            this.PosX = (double)currPosition.X;
            this.PosY = (double)currPosition.Y;
            startMove = currPosition;
            Moving = true;
            direction = new Vector(x - PosX, y - PosY);
            moveDestination = new Vector(x, y);

            double dist = Math.Sqrt((direction.X * direction.X + direction.Y * direction.Y));
            this.moveDuration =
                dist / this.Velocity * 1000; // speed is in u/s, not u/ms
            /*

              t = d/v

             */

            this.MoveDistance = dist;

            lastMove = DateTime.Now;
        }
Exemple #3
0
 public double DistanceTo(Vector otherdude)
 {
     return Math.Sqrt(((otherdude.X - PosX) * (otherdude.X - PosX)) + ((otherdude.Y - PosY) * (otherdude.Y - PosY)));
 }