コード例 #1
0
ファイル: Drone.cs プロジェクト: rubna/MetroidClone
        void StateFollowing()
        {
            targetRot += 4;
            targetRot %= 360;

            acceleration = Vector2.Zero;

            //follow player
            targetPosition = World.Player.Position + new Vector2(-World.Player.GetFlip * 20, -20) + new Vector2(7, targetRot).ToCartesian() * new Vector2(0.6f, 1);

            FlipX = World.Player.Position.X > Position.X;

            //if ((targetPosition - Position).Length() > 0)
            {
                Vector2 speedPlus = (targetPosition - Position).ToPolar();
                //speedPlus.X = Math.Min(speedPlus.X * 0.01f, 0.3f);
                speedPlus.X *= 0.01f;
                speedPlus = speedPlus.ToCartesian();
                acceleration += speedPlus;
            }

            acceleration = acceleration.ToPolar();
            acceleration.X = Math.Min(maxAcceleration, acceleration.X);
            acceleration = acceleration.ToCartesian();
            Speed += acceleration;
        }