static void Main(string[] args) { Console.CursorVisible = false; //border Walls walls = new Walls(80, 25); walls.Draw(); //Snake Point p = new Point(5, 5, '*'); Snake snake = new Snake(p, 4, Direction.Right); snake.Draw(); Food simpleFood = new Food(80, 25, '#'); Point food1 = simpleFood.CreateFood(); food1.Draw(); //gra while (true) { if (walls.IsHit(snake) || snake.IsHitTail()) { break; } if (snake.Eat(food1)) { food1 = simpleFood.CreateFood(); food1.Draw(); } else { snake.Move(); } Thread.Sleep(100); if (Console.KeyAvailable) { ConsoleKeyInfo key = Console.ReadKey(); snake.ControlMove(key.Key); } } Console.ForegroundColor = ConsoleColor.Red; Console.SetCursorPosition(35, 10); Console.Write("Game Over"); Console.SetCursorPosition(27, 13); Console.Write("Made by Stanislav Mishchenko"); Console.ReadLine(); }
static void Main(string[] args) { Console.SetWindowSize(80, 25); Console.ForegroundColor = ConsoleColor.Magenta; Console.WriteLine("Press 'enter' to start the game :)"); Console.ResetColor(); Console.ReadLine(); Walls walls = new Walls(80, 25); walls.Draw(); // Отрисовка точек Point p = new Point(4, 6, '*'); Snake snake = new Snake(p, 5, Direction.RIGHT); snake.Draw(); FoodCreator foodCreator = new FoodCreator(80, 25, '$'); Point food = foodCreator.CreateFood(); food.Draw(); while (true) { if (walls.IsHit(snake) || snake.IsHitTail()) { break; } if (snake.Eat(food)) { food = foodCreator.CreateFood(); food.Draw(); } else { snake.Move(); } Thread.Sleep(100); if (Console.KeyAvailable) { ConsoleKeyInfo key = Console.ReadKey(); snake.HandleKey(key.Key); } } WriteGameOver(); Console.ReadLine(); }