Ejemplo n.º 1
0
        public void IncLength()
        {
            int x = (int)CoordsX[0];
            int y = (int)CoordsY[0];

            switch (Direction)
            {
            case Side.Up: y -= 1; break;

            case Side.Right: x += 2; break;

            case Side.Down: y += 1; break;

            case Side.Left: x -= 2; break;
            }

            CoordsX.Add(0);
            CoordsY.Add(0);
            for (int i = CoordsX.Count - 1; i > 0; i--)
            {
                CoordsX[i] = CoordsX[i - 1];
                CoordsY[i] = CoordsY[i - 1];
            }
            CoordsX[0] = x;
            CoordsY[0] = y;
            Length++;
        }
Ejemplo n.º 2
0
 public Food(int Width, int Height, char Sym = '@')
 {
     Symbol       = Sym;
     WindowWidth  = Width;
     WindowHeight = Height;
     FoodCounter  = 5;
     for (int i = 0; i < FoodCounter; i++)
     {
         CoordsX.Add(rand.Next(WindowWidth - 6) + 4);
         if ((int)CoordsX[i] % 2 != 0)
         {
             CoordsX[i] = (int)CoordsX[i] - 1;
         }
         CoordsY.Add(rand.Next(WindowHeight - 10) + 5);
         IsPick.Add(false);
     }
 }
Ejemplo n.º 3
0
 public Snake(char Symbol)
 {
     for (int i = 0; i < startLength; i++)
     {
         CoordsX.Add(0);
         CoordsY.Add(0);
     }
     Alive       = true;
     this.Symbol = Symbol;
     CoordsX[0]  = 10;
     CoordsY[0]  = 5;
     Length      = startLength;
     for (int i = 1; i < Length; i++)
     {
         CoordsX[i] = (int)CoordsX[i - 1] - 1;
         CoordsY[i] = (int)CoordsY[i - 1];
     }
     Direction = Side.Right;
 }