Esempio n. 1
0
 public void Level(Wall wall, Snake snake)
 {
     if (snake.body.Count == 4)
     {
         Console.Clear();
         wall.cnt++;
         wall.wallpoint();
         int j1 = 5;
         for (int i = 0; i < snake.body.Count; i++)
         {
             snake.body[i].x = j1;
             snake.body[i].y = 15;
             j1++;
         }
     }
     if (snake.body.Count == 8)
     {
         Console.Clear();
         wall.cnt++;
         wall.wallpoint();
         int j2 = 5;
         for (int i = 0; i < snake.body.Count; i++)
         {
             snake.body[i].x = j2;
             snake.body[i].y = 15;
             j2++;
         }
     }
 }
Esempio n. 2
0
 public static void Func()
 {
     while (k == 0)
     {
         if ((food.location.x == snake.body[0].x && food.location.y == snake.body[0].y))
         {
             wall.Level(wall, snake);
             if (snake.body.Count > 1)
             {
                 snake.body.Add(new Point(snake.body[snake.body.Count - 1].x, snake.body[snake.body.Count - 1].y));
             }
             else
             {
                 snake.body.Add(new Point(5, 5));
             }
             food.SetRandomPosition(wall, snake);
             food.Draw();
         }
         if (direction == 1)
         {
             snake.Move(0, 1);
         }
         if (direction == 2)
         {
             snake.Move(0, -1);
         }
         if (direction == 3)
         {
             snake.Move(1, 0);
         }
         if (direction == 4)
         {
             snake.Move(-1, 0);
         }
         if (snake.CollisionWithWall(snake, wall))
         {
             snake.RecordSave(username, snake.body.Count);
             k = 1;
         }
         food.Draw();
         snake.Draw();
         wall.wallpoint();
         wall.Draw();
         Thread.Sleep(n);
     }
 }