Example #1
0
 public void CleanMap()
 {
     for(int i = 0;i < Height;i++)
     {
         for(int j = 0;j < Width;j++)
         {
             map[i, j] = new Tile();
         }
     }
 }
Example #2
0
 private static int GetProcessedTextureId(Tile tile)
 {
     if (tile.IsPlayer)
     {
         return (int)textures.player;
     }
     if (tile.mass > (int)textures.rock)
     {
         return (int)textures.rock;
     }
     return tile.mass;
 }
Example #3
0
 public static double[] GetForce(Tile tile) => GetForce(tile.velocity, tile.mass);
Example #4
0
 public static int[] GetRoundedVelocity(Tile tile) => GetRoundedVelocity(tile.velocity);
Example #5
0
 /// <summary>
 /// gets tile1's relative Force to tile2.  
 /// </summary>
 /// <param name="tile1"></param>
 /// <param name="tile2"></param>
 /// <returns></returns>
 public static double[] GetForce(Tile tile1, Tile tile2)
 {
     double[] getForce = GetForce(tile1);
     double[] otherForce = GetForce(tile2);
     getForce[0] -= otherForce[0];
     getForce[1] -= otherForce[1];
     return getForce;
 }
Example #6
0
 private static Image GetTexture(Tile tile) => GetTexture(GetProcessedTextureId(tile));
Example #7
0
 public void PlacePlayer(int[] coords, int mass)
 {
     Tile tile = new Tile(mass);
     tile.IsPlayer = true;
     PlaceOneTile(coords, tile);
 }
Example #8
0
 public void PlaceOneTile(int[] coords, Tile tile) => map[coords[0], coords[1]].SetTile(tile);
Example #9
0
 private static void CollideTileElastic(Tile tile1,Tile tile2, double[] velocity1,double[] forceTotal, int mass2)
 {
     //Debug.Write("colliding");
     if (forceTotal[0] / mass2 >= velocity1[0] && forceTotal[1] / mass2 >= velocity1[0])//extra force or equel
     {
         tile2.velocity[0] = velocity1[0];
         tile2.velocity[1] = velocity1[1];
         double[] force1 = forceTotal;
         force1[0] -= (velocity1[0] * mass2);
         force1[1] -= (velocity1[1] * mass2);
         double[] newVelocity1 = Helper.GetVelocity(force1, tile1.mass);
         tile1.velocity[0] = newVelocity1[0];
         tile1.velocity[1] = newVelocity1[1];
         return;
     }
     //less force
     else
     {
         double[] newVelocity2 = Helper.GetVelocity(forceTotal, mass2);
         tile2.velocity = newVelocity2;
         tile1.velocity = new double[2];
     }
 }