static void Main(string[] args) { Console.SetBufferSize(82, 27); //Отрисовка рамочки. HorisontalLine lowLine = new HorisontalLine(1, 78, 25, '='); HorisontalLine topLine = new HorisontalLine(1, 78, 2, '='); VerticalLine leftLine = new VerticalLine(1, 3, 24, '|'); VerticalLine rightLine = new VerticalLine(78, 3, 24, '|'); lowLine.DrawLine(); topLine.DrawLine(); leftLine.DrawLine(); rightLine.DrawLine(); //Отрисовка еды. FoodCreator foodCreator = new FoodCreator(82, 27, '@'); Point food = foodCreator.CreateFood(); food.Draw(); //Отрисовка змейки. Point startPoint = new Point(3, 4, '*'); Snake snake = new Snake(startPoint, 4, Direction.RIGHT); snake.DrawLine(); while (true) { if (snake.Eat(food)) { food = foodCreator.CreateFood(); food.Draw(); } else { snake.Move(); } Thread.Sleep(100); if (Console.KeyAvailable) { ConsoleKeyInfo key = Console.ReadKey(); snake.Control(key.Key); } //Thread.Sleep(100); //snake.Move(); } Console.ReadLine(); }
static void Main(string[] args) { Walls walls = new Walls(30, 20); walls.Draw(); Point startPoint = new Point(4, 4, '*'); Snake snake = new Snake(startPoint, 5, Direction.RIGHT); snake.Draw(); FoodCreator foodCreator = new FoodCreator(30, 20, 'g'); Point food = foodCreator.CreateFood(); food.Draw(); while (true) { Console.CursorVisible = false; if (walls.IsHit(snake) || snake.IsHitTail()) { break; } if (snake.Eat(food)) { food = foodCreator.CreateFood(); food.Draw(); } else { snake.Move(); } Thread.Sleep(200); if (Console.KeyAvailable) { ConsoleKeyInfo inputKey = Console.ReadKey(); snake.Control(inputKey); } } Console.SetCursorPosition(3, 10); Console.WriteLine("Game over. Press enter."); //end of porgram Console.ReadLine(); }