public Wall(int mapWidth, int mapHeight) { wallList = new List <Figure>(); HorizontalLine upline = new HorizontalLine(0, mapWidth - 2, 0, '+'); HorizontalLine downline = new HorizontalLine(0, mapWidth - 2, mapHeight - 1, '+'); VerticalLine leftline = new VerticalLine(0, mapHeight - 1, 0, '+'); VerticalLine rightLine = new VerticalLine(0, mapHeight - 1, mapWidth - 2, '+'); wallList.Add(upline); wallList.Add(downline); wallList.Add(leftline); wallList.Add(rightLine); }
static void Main(string[] args) { Console.SetWindowSize(80, 25); Console.SetBufferSize(80, 25); //Отрисовка рамочки HorizontalLine upLine = new HorizontalLine(0, 78, 0, '+'); HorizontalLine downLine = new HorizontalLine(0, 78, 24, '+'); VerticalLine leftLine = new VerticalLine(0, 0, 24, '+'); VerticalLine rightLine = new VerticalLine(78, 0, 24, '+'); upLine.Draw(); downLine.Draw(); leftLine.Draw(); rightLine.Draw(); // отрисовка точек Point p = new Point(4, 5, '*'); Snake snake = new Snake(p, 4, Direction.RIGHT); snake.Draw(); //Создание еды FoodCreator foodCreator = new FoodCreator(80, 25, '$'); Point food = foodCreator.CreateFood(); food.Draw(); 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.HandleKey(key.Key); } } }