public Walls(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, 0, mapHeight - 1, '+'); VerticalLine rightLine = new VerticalLine(mapWidth - 2, 0, mapHeight - 1, '+'); wallList.Add(upLine); wallList.Add(downLine); wallList.Add(leftLine); wallList.Add(rightLine); }
static void Main(string[] args) { Console.SetBufferSize(80, 25); //отрисовка рамки HorizontalLine upline = new HorizontalLine(0, 78, 0, '+'); upline.Drow(); HorizontalLine downline = new HorizontalLine(0, 78, 24, '+'); downline.Drow(); VerticalLine leftline = new VerticalLine(0, 0, 24, '+'); leftline.Drow(); VerticalLine rigthline = new VerticalLine(78, 0, 24, '+'); rigthline.Drow(); //отрисовка точек Point p1 = new Point(7, 18, '*'); Snake snake = new Snake(p1, 4, Direction.RIGTH); snake.Drow(); //генерация еды 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(120); if (Console.KeyAvailable) { ConsoleKeyInfo key = Console.ReadKey(); snake.Handle(key.Key); } } }
static void Main(string[] args) { Console.SetBufferSize(80, 25); //Отрисовка рамочки HorizontalLine upLine = new HorizontalLine(0, 78, 0, '+'); VerticalLine leftLine = new VerticalLine(0, 24, 0, '+'); VerticalLine rightLine = new VerticalLine(0, 24, 78, '+'); HorizontalLine downLine = new HorizontalLine(0, 78, 24, '+'); upLine.Draw(); leftLine.Draw(); rightLine.Draw(); downLine.Draw(); //Отрисовка точек Point p = new Point(4, 5, '*'); Snake snake = new Snake(p, 4, Direction.RIGHT); snake.Draw(); Console.ReadLine(); }