Exemple #1
0
        private void GenerateBody()
        {
            int x = DefaultX;
            int y = DefaultY;

            for (int i = 0; i < SnakeLength; i++)
            {
                var point = new SnakePoint(x, y);
                this.body.Enqueue(point);
                x++;
            }
        }
Exemple #2
0
        public SnakePoint GetHead()
        {
            SnakePoint oldHead = this.body.Last();

            int newX = oldHead.CoordinateX;
            int newY = oldHead.CoordinateY;

            switch (this.Direction)
            {
            case Direction.Right:
                newX++; break;

            case Direction.Left:
                newX--; break;

            case Direction.Down:
                newY++; break;

            case Direction.Up:
                newY--; break;
            }

            return(new SnakePoint(newX, newY));
        }