public virtual void Move(WorldGraphicsComponent toMove, long deltaTime)
        {
            double speed = _speed * deltaTime;

            if (!CollsionDetector.OverLapping(toMove.Center, _target))
            {
                /*
                 *      I hate movement so i stole this is form here
                 *      http://stackoverflow.com/questions/13849185/moving-an-object-along-a-straight-line-at-a-constant-speed-from-point-a-to-b
                 */

                double tx    = _target.X - toMove.Center.X;
                double ty    = _target.Y - toMove.Center.Y;
                double dist  = Math.Sqrt(tx * tx + ty * ty);
                double rad   = Math.Atan2(ty, tx);
                double angle = rad / Math.PI * 180;

                double velX = (tx / dist) * speed;
                double velY = (ty / dist) * speed;

                toMove.Center = toMove.Center.Add(new Point2D(velX, velY));
            }
        }
Exemple #2
0
        /// <summary>
        /// Moves the Camera to the Subject
        /// </summary>
        private void MoveCameraToSubject()
        {
            WorldGraphicsComponent wgc = _gameObject.GetComponent <WorldGraphicsComponent>();

            Utils.SetCamreaCenter(wgc.Center);
        }