Exemplo n.º 1
0
 //Constructor
 public Snake(int _panelWidth)
 {
     this.SnakeSize  = 4;
     this.panelWidth = _panelWidth;
     snakeBody       = new SnakeParts[4];
     snakeBody[0]    = new SnakeParts(panelWidth, 50);
     snakeBody[1]    = new SnakeParts(panelWidth + 15, 50);
     snakeBody[2]    = new SnakeParts(panelWidth + 25, 50);
     snakeBody[3]    = new SnakeParts(panelWidth + 35, 50);
 }
Exemplo n.º 2
0
 //Move snake
 public void Move(Direction dir)
 {
     myDir = dir;
     if (dir != null)
     {
         for (int i = snakeBody.Length - 1; i > 0; i--)
         {
             snakeBody[i] = new SnakeParts(snakeBody[i - 1]._x, snakeBody[i - 1]._y);
         }
         snakeBody[0] = new SnakeParts(snakeBody[0]._x + dir._x, snakeBody[0]._y + dir._y);
     }
 }