Exemple #1
0
    public void ResetVectorField(int gridWidthIndex, int gridHeightIndex)
    {
        float rAngle = RandomFuncts.GetRandomFloat((float)-Math.PI, (float)Math.PI);
        float rVel   = RandomFuncts.GetRandomFloat(0, 20);

        float x = (float)Math.Sin(rAngle) * rVel;
        float y = (float)-Math.Cos(rAngle) * rVel;

        for (int j = -1; j < 2; j++)
        {
            for (int k = -1; k < 2; k++)
            {
                this.vfVecX[MathFuncts.Mod(gridWidthIndex - j, this.gridSize), MathFuncts.Mod(gridHeightIndex - j, this.gridSize)] = x;
                this.vfVecY[MathFuncts.Mod(gridWidthIndex - k, this.gridSize), MathFuncts.Mod(gridHeightIndex - k, this.gridSize)] = y;
            }
        }
    }
Exemple #2
0
 public void WrapAroundWindow(int index)
 {
     if (this.posX[index] > this.width)
     {
         this.posX[index] = MathFuncts.Mod((int)(this.posX[index] - this.width), (int)this.width);
     }
     else if (this.posX[index] < 0)
     {
         this.posX[index] = MathFuncts.Mod((int)((int)this.posX[index] + this.width), (int)this.width);
     }
     if (this.posY[index] > this.height)
     {
         this.posY[index] = MathFuncts.Mod((int)(this.posY[index] - this.height), (int)this.height);
     }
     else if (this.posY[index] < 0)
     {
         this.posY[index] = MathFuncts.Mod((int)(this.posY[index] + this.height), (int)this.height);
     }
 }