public void menu() { Console.Title = "Лабораторная работа №3"; wall.clear(); Console.SetWindowSize(x, y); Console.SetCursorPosition(32, 20); Console.Write("выберите вариант"); Console.SetCursorPosition(32, 21); Console.WriteLine("(1) Точка"); Console.SetCursorPosition(32, 22); Console.WriteLine("(2) Линия"); Console.SetCursorPosition(32, 23); Console.WriteLine("(0) Возврат в главное меню"); int menuNum; Console.SetCursorPosition(2, y - 2); Console.Write("Ваш выбор: "); menuNum = int.Parse(Console.ReadLine()); switch (menuNum) { case 1: this.point(); break; case 2: this.line(); break; case 0: Program.Main(); break; } }
public void Run() { Walls wall = new Walls(85, 43); wall.clear(); Point food = new Point(4, 2, '$'); food.Draw(); Snake snake = new Snake(p, 4, Direction.RIGHT); snake.Draw(); bool run = true; while (run) { if (snake.Eat(food)) { food = new Point(food.x + 2, food.y + 1, '$'); food.Draw(); } else { snake.Move(); } if (crash()) { run = false; Console.SetCursorPosition(32, 20); Console.WriteLine("ЗМЕЙКА КАПУТ"); } Thread.Sleep(100); if (Console.KeyAvailable) { ConsoleKeyInfo key = Console.ReadKey(); snake.HandleKey(key.Key); } } }