예제 #1
0
        public void Moving()
        {
            SnakeBlock tempNode = head;

            for (var i = 0; i < count; i++)
            {
                tempNode.Moving();
                tempNode = tempNode.Previous;
            }
        }
예제 #2
0
        public void Turn(Direction direction)
        {
            SnakeBlock tempNode = head.Previous;
            Point      fixState = new Point(head.Position.X, head.Position.Y);

            head.ToTurn(fixState, direction);
            for (var i = 0; i < count - 1; i++)
            {
                tempNode.ToTurn(fixState, direction);
                tempNode = tempNode.Previous;
            }
        }
예제 #3
0
        public void Draw()
        {
            spriteBatch.Begin();
            SnakeBlock tempNode = head;

            for (var i = 0; i <= count; i++)
            {
                spriteBatch.Draw(rectangleBlock, tempNode.ToRectangle(), tempNode.Color);
                tempNode = tempNode.Previous;
            }
            spriteBatch.End();
        }
예제 #4
0
        public void Add(SnakeBlock snakeBlock)
        {
            SnakeBlock node = snakeBlock;

            if (head == null)
            {
                head          = node;
                head.Next     = node;
                head.Previous = node;
            }
            else
            {
                node.Previous      = head.Previous;
                node.Next          = head;
                head.Previous.Next = node;
                head.Previous      = node;
            }
            count++;
        }
예제 #5
0
 public void Clear()
 {
     head  = null;
     count = 0;
     BeginInitialise();
 }