Esempio n. 1
0
 /// <summary>
 /// Intialize a entity with randomized parameters
 /// </summary>
 /// <param name="world">The world that this entity belongs to</param>
 public BaseEntity(World world)
 {
     mParent = world;
     mPosition = new Vector2D(mParent.WorldSeed.NextDouble() * 10.0 - 5.0, mParent.WorldSeed.NextDouble() * 10.0 - 5.0);
     mSpeed = 1;
     mMass = mParent.WorldSeed.NextDouble() * 50 + 10;
     mDirection = new Vector2D(mParent.WorldSeed.NextDouble() * 2.0 - 1.0, mParent.WorldSeed.NextDouble() * 2.0 - 1.0);
 }
Esempio n. 2
0
 public override void process()
 {
     double length = mDirection.Length;
     if (length > 0)
     {
         mDirection = (1 / length) * mDirection;
         mSpeed *= length;
     }
     else
     {
         mDirection.x = 0; mDirection.y = 0;
         mSpeed = 1;
     }
     if (mSpeed > 2)
         mSpeed = 2;
     if (mPosition.x * mPosition.x + mPosition.y * mPosition.y > 4)
         mDirection = (-1) * mDirection;
     //TODO replace with charge setting
     mCharge += mSpeed * 0.1;
     mCharge *= 0.77;
     //TODO replace with clock setting
     mPosition += (0.01 * mSpeed) * mDirection;
     Console.WriteLine(mDirection.x + " " + mDirection.y);
 }
Esempio n. 3
0
 public abstract Vector2D count(Vector2D v);
Esempio n. 4
0
 protected override void addForce(Vector2D vector)
 {
     mDirection += (1 / mMass) * vector;
 }
 protected abstract void addForce(Vector2D vector);