示例#1
0
文件: foodpoint.cs 项目: Ihor01/snake
 public point Next(snake Snake, walls wall)
 {
     int x;
     int y;
     point p;
     do
     {
         x = rnd.Next(1, whidth - 1);
         y = rnd.Next(1, height - 1);
         p = new point(x, y, s);
     } while (Snake.IsHit(p) || wall.IsHit(p));
     return p;
 }
示例#2
0
文件: Game.cs 项目: Ihor01/snake
 public int Start(int lvl)
 {
     Console.Clear();
     Console.SetCursorPosition(width / 2 - 5, height / 2);
     Console.Write("Уровень " + lvl.ToString());
     Thread.Sleep(1000);
     Console.Clear();
     Console.SetCursorPosition(3, height + 2);
     Console.Write("Счет:");
     Console.SetCursorPosition(10, height + 2);
     Console.Write("Уровень:");
     Console.SetCursorPosition(13, height + 3);
     Console.Write(lvl);
     Snake = new snake(pos, 4, direction.RIGHT);
     Console.SetCursorPosition(5, height + 3);
     Console.Write(Snake.GetScore() * speed);
     wall = new walls(width, height, lvl);
     fp = new foodpoint(width, height, 2);
     food = fp.Next(Snake, wall);
     food.Draw();
     Play(1);
     int sc = Snake.GetScore() * speed;
     Snake.ResetScore();
     return sc;
 }