Exemplo n.º 1
0
 private void timer1_Tick(object sender, EventArgs e)
 {
     checkCoords();
     if (!food)
     {
         coordsFood = getCoordsFood();
         food = true;
     }
     checkFood();
     Coords temp = new Coords(snakeBody[0].Coords.X, snakeBody[0].Coords.Y);
     snakeBody[0].Coords.X = coordsHead.X;
     snakeBody[0].Coords.Y = coordsHead.Y;
     Coords temp1;
     for (int i = 1; i < snakeBody.Count; i++)
     {
         temp1 = new Coords(snakeBody[i].Coords.X, snakeBody[i].Coords.Y);
         snakeBody[i].Coords.X = temp.X;
         snakeBody[i].Coords.Y = temp.Y;
         temp = temp1;
     }
     coordsHead.X += routeX;
     coordsHead.Y += routeY;
     DrawSnake();
     if (fail())
     {
        // MessageBox.Show("Лох");
         StandartSettings();
     }
        // MessageBox.Show(snakeBody[0].Coords.X.ToString() + "  " + snakeBody[1].Coords.X.ToString());
 }
Exemplo n.º 2
0
 public SnakeBlock(Coords coords)
 {
     _coords = coords;
 }
Exemplo n.º 3
0
 private void StandartSettings()
 {
     snakeBody.RemoveRange(0, snakeBody.Count);
     snakeBody.Add(new SnakeBlock(new Coords(1, 1)));
     //snakeBody.Add(new SnakeBlock(new Coords(0, 1)));
     coordsHead = new Coords(2, 1);
     routeX = 1;
     routeY = 0;
 }