Get Xna Random Direction - CSharp Microsoft.Xna.Framework

CSharp examples for Microsoft.Xna.Framework:Xna

Description

Get Xna Random Direction

Demo Code


using Microsoft.Xna.Framework;
using System;//from   w  w  w  .  j  a  v a 2 s. co m

public class Main{
        public static Vector2 GetRandomDirection(Random random) {
            double azimuth = random.NextDouble() * 2 * System.Math.PI;
            return new Vector2((float) System.Math.Cos(azimuth), (float) System.Math.Sin(azimuth));
        }
}

Related Tutorials