Exemple #1
0
 public static void Limit(ref PVector2 val, FInt maxLength)
 {
     var l = val.Length();
     if (l > maxLength) {
         var ratio = maxLength / l;
         val.X *= ratio;
         val.Y *= ratio;
     }
 }
Exemple #2
0
        public Bug(PVector2 p, PVector2 v, List<Boid> bs, Random r)
            : base(p, v, bs, new FInt(3), r)
        {
            AlignmentWeight = new FInt(0.1);
            CohesionWeight = new FInt(1.0);
            SeperationWeight = new FInt(2.0);
            Momentum = new FInt(5.0);
            RandomWeight = new FInt(0.1);

            MaxVelocity = new FInt(5);
            VisionRangeSquared = new FInt(25.0 * 25.0);
        }
Exemple #3
0
        protected virtual void ResetBoid(Boid b)
        {
            var direction = MathHelper.Lerp(0, MathHelper.TwoPi, (float)Random.NextDouble());
            var speed = Random.NextDouble() * MaxVelocity.ToDouble();
            var v = PVector2.Zero;
            v.X = new FInt((Math.Cos(direction) * speed));
            v.Y = new FInt((Math.Sin(direction) * speed));

            var p = new PVector2((FInt)Random.Next(-400, 400), (FInt)Random.Next(-400, 400));
            b.Position = p;
            b.VelocityPerTick = v;
            b.Dead = false;
        }
Exemple #4
0
 public void DistanceSquaredTo(ref PVector2 other, out FInt i)
 {
     PVector2.Sub(ref this, ref other, out scratchV);
     scratchV.LengthSquared(out i);
 }
Exemple #5
0
 public static void Sub(ref PVector2 a, ref PVector2 b, out PVector2 dest)
 {
     FInt.Sub(ref a.X, ref b.X, out dest.X);
     FInt.Sub(ref a.Y, ref b.Y, out dest.Y);
 }
Exemple #6
0
 public static void Multiply(ref PVector2 v, ref FInt i, out PVector2 o)
 {
     FInt.Multiply(ref v.X, ref i, out o.X);
     FInt.Multiply(ref v.Y, ref i, out o.Y);
 }
Exemple #7
0
 public static void Add(ref PVector2 a, ref PVector2 b, out PVector2 c)
 {
     FInt.Add(ref a.X, ref b.X, out c.X);
     FInt.Add(ref a.Y, ref b.Y, out c.Y);
 }