static void Main(string[] args) { //set screen size Console.SetBufferSize(80, 25); //create HorizontalLine object HorizontalLine upLine = new HorizontalLine(0, 78, 0, '*'); upLine.Draw(); HorizontalLine downLine = new HorizontalLine(0, 78, 24, '*'); downLine.Draw(); //create VerticalLine object VerticalLine leftLine = new VerticalLine(0, 24, 0, '*'); leftLine.Draw(); VerticalLine rightLine = new VerticalLine(0, 24, 78, '*'); rightLine.Draw(); //create a symbol object Point p1 = new Point(1, 3, '*'); p1.Draw(); Point p2 = new Point(4, 5, '#'); p2.Draw(); Console.ReadKey(); }
static void Main(string[] args) { Console.SetBufferSize(80, 25); HorizontalLine uline = new HorizontalLine(0, 78, 0, '+'); HorizontalLine dline = new HorizontalLine(0, 78, 24, '+'); VerticalLine lline = new VerticalLine(0, 24, 0, '+'); VerticalLine rline = new VerticalLine(0, 24, 78, '+'); uline.Draw(); dline.Draw(); lline.Draw(); rline.Draw(); Point p = new Point(4, 5, '*'); Snake snake = new Snake(p, 4, Direction.RIGHT); snake.Draw(); while (true) { System.Threading.Thread.Sleep(150); snake.Move(); if (Console.KeyAvailable) { ConsoleKeyInfo key = Console.ReadKey(); snake.HandleKey(key.Key); } } }
static void Main(string[] args) { /// ----- Lesson 10 ----- /// "Змейка" в движении /// /* Отрисовка Рамочки */ Console.SetBufferSize(80, 25); // Блокируем окошко HorizontalLine TopLine = new HorizontalLine(0, 78, 0, '+'); // Создание линии HorizontalLine BottomLine = new HorizontalLine(0, 78, 24, '+'); VerticalLine LeftLine = new VerticalLine(0, 24, 0, '+'); VerticalLine RightLine = new VerticalLine(0, 24, 78, '+'); TopLine.Draw(); // Отрисовка линии BottomLine.Draw(); LeftLine.Draw(); RightLine.Draw(); /* Отрисовка змейки */ Point p = new Point(2, 2, '*'); // Стартовая позиция хвоста Snake snake = new Snake(p, 5, Direction.UP); // Размер и направление змейки snake.Draw(); // Отрисовать змейку snake.Move(); // Передвинуть змейку Thread.Sleep(300); // Выполнить следующую команду с задержкой snake.Move(); Thread.Sleep(300); snake.Move(); Thread.Sleep(300); snake.Move(); Thread.Sleep(300); snake.Move(); Thread.Sleep(300); snake.Move(); Console.ReadLine(); }
static void Main(string[] args) { Console.SetWindowSize(1, 1); Console.SetBufferSize(80, 25); Console.SetWindowSize(80, 25); // Отрисовка рамочки HorizontalLine upLine = new HorizontalLine(0, 78, 0, '+'); upLine.Draw(); HorizontalLine downLine = new HorizontalLine(0, 78, 24, '+'); downLine.Draw(); VerticalLine leftLine = new VerticalLine(0, 0, 24, '+'); leftLine.Draw(); VerticalLine rightLine = new VerticalLine(78, 0, 24, '+'); rightLine.Draw(); //отрисовка точек Point p = new Point(4, 5, '*'); Snake snake = new Snake(p, 4, Direction.RIGHT); snake.Draw(); while(true) { if(Console.KeyAvailable) { ConsoleKeyInfo key = Console.ReadKey(); snake.HandleKey(key.Key); } Thread.Sleep(100); snake.Move(); } // Console.ReadLine(); }
static void Main(string[] args) { Console.SetBufferSize(80, 25); //Отрисовка рамочки HorizontalLine upLine = new HorizontalLine(0, 78, 0, '+'); HorizontalLine downLine = new HorizontalLine(0, 78, 24, '+'); VerticalLine leftLine = new VerticalLine(0,24,0,'+'); VerticalLine rightLine = new VerticalLine(0, 24, 78, '+'); upLine.Draw(); downLine.Draw(); leftLine.Draw(); rightLine.Draw(); //HorizontalLine line = new HorizontalLine(5,10,8,'+'); //line.Draw(); //VerticalLine vLine = new VerticalLine(4,20,5,'*'); //vLine.Draw(); Point p = new Point(4, 5, '*'); Snake snake = new Snake(p, 4, Diraction.RIGHT); snake.Draw(); Console.ReadLine(); }
static void Main(string[] args) { Console.SetBufferSize(80, 25); HorizontalLine upLine = new HorizontalLine(0, 78, 0, '+'); HorizontalLine downLine = new HorizontalLine(0, 78, 24, '+'); VerticalLine leftLine = new VerticalLine(1, 24, 0, '+'); VerticalLine rightLine = new VerticalLine(1, 24, 78, '+'); upLine.Draw(); downLine.Draw(); leftLine.Draw(); rightLine.Draw(); Point p = new Point(1, 4, '*'); Snake snake = new Snake(p, 5, Direction.RIGHT); snake.Draw(); snake.Move(); Thread.Sleep(300); snake.Move(); Thread.Sleep(300); snake.Move(); Thread.Sleep(300); snake.Move(); Thread.Sleep(300); snake.Move(); Thread.Sleep(300); snake.Move(); Thread.Sleep(300); snake.Move(); Thread.Sleep(300); snake.Move(); Thread.Sleep(300); Console.ReadLine(); }
static void Main(string[] args) { Console.SetWindowSize(80, 25); Console.SetBufferSize(Console.WindowWidth, Console.WindowHeight); HorizontalLine h1 = new HorizontalLine(1, 80, 1, '*'); HorizontalLine h2 = new HorizontalLine(1, 80, 24, '*'); VerticalLine v1 = new VerticalLine(1, 24, 1, '*'); VerticalLine v2 = new VerticalLine(1, 24, 79, '*'); h1.Draw(); h2.Draw(); v1.Draw(); v2.Draw(); Point p1 = new Point(7, 7, '*'); Snake snake = new Snake(p1, 4, Direction.RIGHT); snake.Draw(); snake.Move(); Thread.Sleep(300); snake.Move(); Thread.Sleep(300); snake.Move(); Thread.Sleep(300); snake.Move(); Thread.Sleep(300); snake.Move(); Console.ReadLine(); }
public static void Main(string[] args) { //create borders HorizontalLine hLine1 = new HorizontalLine(0, 30, 2, '+'); HorizontalLine hLine2 = new HorizontalLine(0, 30, 20, '+'); VerticalLine vLine1 = new VerticalLine(2, 20, 0, '+'); VerticalLine vLine2 = new VerticalLine(2, 20, 30, '+'); //draw borders hLine1.Draw(); hLine2.Draw(); vLine1.Draw(); vLine2.Draw(); //create snake Point start = new Point(5, 5, '*'); Snake sn = new Snake(start, 7, Direction.RIGHT); sn.Draw(); while (true) { if (Console.KeyAvailable) { ConsoleKeyInfo key = Console.ReadKey(); sn.HandleKey(key.Key); } System.Threading.Thread.Sleep(300); sn.Move(); } Console.ReadLine(); }
static void Main(string[] args) { int width, height; Console.SetBufferSize(width = Console.WindowWidth, height = Console.WindowHeight); //Отрисовка рамки HorizontalLine upLine = new HorizontalLine(0, width - 1, 1, '+'); HorizontalLine downLine = new HorizontalLine(0, width - 1, height - 2, '+'); VerticalLine leftLine = new VerticalLine(0, 1, height - 3, '+'); VerticalLine rightLine = new VerticalLine(width - 1, 1, height - 3, '+'); upLine.Draw(); downLine.Draw(); leftLine.Draw(); rightLine.Draw(); //Отрисовка точек Point p = new Point(4, 5, '*'); Snake snake = new Snake(p, 4, Direction.RIGHT); snake.Draw(); while (true) { if (Console.KeyAvailable) { ConsoleKeyInfo key = Console.ReadKey(); snake.HandleKey(key.Key); } Thread.Sleep(100); snake.Move(); } }
static void Main(string[] args) { Console.WriteLine("DIMA BOBROVICH"); HorizontalLine topLine = new HorizontalLine(0, 60, 1, '+'); HorizontalLine botLine = new HorizontalLine(0, 60, 20, '+'); VerticalLine leftLine = new VerticalLine(0, 1, 20, '+'); VerticalLine RightLine = new VerticalLine(60, 1, 20, '+'); topLine.Draw(); botLine.Draw(); leftLine.Draw(); RightLine.Draw(); Point p1 = new Point(1, 4, '*'); Snake snake = new Snake(p1, 4, Direction.RIGHT); Food f = new Food(60, 20, '@'); Point food = f.CreateFood(); food.Draw(); var i = 0; while (true) { if (i > 8) { i = 0; } if (Console.KeyAvailable) { ConsoleKeyInfo key = Console.ReadKey(); if (key.Key == ConsoleKey.LeftArrow) { snake.direction = Direction.LEFT; } if (key.Key == ConsoleKey.RightArrow) { snake.direction = Direction.RIGHT; } if (key.Key == ConsoleKey.UpArrow) { snake.direction = Direction.DOWN; } if (key.Key == ConsoleKey.DownArrow) { snake.direction = Direction.UP; } } Thread.Sleep(200); snake.Move(i); if (snake.Eat(food)) { food = f.CreateFood(); food.Draw(); } i++; } }
static void Main(string[] args) { //Point p1 = new Point(1, 3, '*'); //p1.Draw(); //Point p2 = new Point(4, 5, '#'); //p2.Draw(); //bool error = false; //bool end = false; HorizontalLine line = new HorizontalLine(0, 40, 0, '+'); HorizontalLine line1 = new HorizontalLine(0, 40, 22, '+'); VerticalLine line2 = new VerticalLine(1, 21, 0, '+'); VerticalLine line3 = new VerticalLine(1, 21, 40, '+'); line.Draw(); line1.Draw(); line2.Draw(); line3.Draw(); Point p = new Point(4, 5, '*'); Snake snake = new Snake(p, 4, Direction.RIGHT); snake.Draw(); FoodCreator foodCreator = new FoodCreator(18, 19, '$'); Point food = foodCreator.CreateFood(); food.Draw(); while (true) { if (snake.Eat(food)) { food = foodCreator.CreateFood(); food.Draw(); } else { snake.Move(); } Thread.Sleep(500); if (Console.KeyAvailable) { ConsoleKeyInfo key = Console.ReadKey(); snake.HandleKey(key.Key); } snake.Move(); } }
static void Main(string[] args) { //Setting Console size and constrainting it Console.SetWindowSize(80, 25); Console.SetBufferSize(80, 25); //Drawing the frame HorizontalLine hLine1 = new HorizontalLine(0, 78, 0, '+'); HorizontalLine hLine2 = new HorizontalLine(0, 78, 24, '+'); VerticalLine vLine1 = new VerticalLine(0, 24, 0, '+'); VerticalLine vLine2 = new VerticalLine(0, 24, 78, '+'); hLine1.Draw(); hLine2.Draw(); vLine1.Draw(); vLine2.Draw(); //Drawing a dot Dot d = new Dot(4, 5, '*'); //Drawing a snake itself Snake snake = new Snake(d, 4, Direction.RIGHT); snake.Draw(); //Creating food for snake FoodCreator foodCreator = new FoodCreator(80, 25, '*'); Dot food = foodCreator.CreateFood(); food.Draw(); //Controlled snake movement while (true) { if (snake.Eat(food)) { food = foodCreator.CreateFood(); food.Draw(); snake.Draw(); } else { snake.Move(); } Thread.Sleep(300); if (Console.KeyAvailable) { ConsoleKeyInfo key = Console.ReadKey(); snake.HandleKey(key.Key); } Thread.Sleep(300); snake.Move(); } }
static void Main(string[] args) { //Размер экрана const int screenWidth = 100; const int screenHeight = 30; //Настраиваем консоль Console.SetWindowSize(screenWidth, screenHeight); Console.SetBufferSize(screenWidth, screenHeight); //Отрисовка рамочки HorizontalLine topLine = new HorizontalLine(0, screenWidth - 2, 0, '+'); HorizontalLine bottomLine = new HorizontalLine(0, screenWidth - 2, screenHeight - 1, '+'); VerticalLine leftLine = new VerticalLine(0, screenHeight - 1, 0, '+'); VerticalLine rightLine = new VerticalLine(0, screenHeight - 1, screenWidth - 2, '+'); topLine.Draw(); bottomLine.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(screenWidth, screenHeight, '$'); 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.SetDirection(key.Key); } } }
static void Main(string[] args) { //Console.SetBufferSize(85,30); //Рисуем рамку HorizontalLine lineUpH = new HorizontalLine(0, 78, 0, '-'); HorizontalLine lineDownH = new HorizontalLine(0, 78, 24, '-'); lineUpH.Draw(); lineDownH.Draw(); VerticalLine lineleftV = new VerticalLine(0, 24, 0, '|'); VerticalLine lineRightV = new VerticalLine(0, 24, 78, '|'); lineleftV.Draw(); lineRightV.Draw(); //Корректируем углы Point corner1 = new Point(0, 0, '+'); Point corner2 = new Point(0, 24, '+'); Point corner3 = new Point(78, 0, '+'); Point corner4 = new Point(78, 24, '+'); corner1.Draw(); corner2.Draw(); corner3.Draw(); corner4.Draw(); //Начальная позиции для змейки Point p = new Point(4, 5, '*'); Snake snake = new Snake(p, 4, Direction.RIGHT); snake.Draw(); while (true) { if (Console.KeyAvailable) { ConsoleKeyInfo key = Console.ReadKey(); // по нажатию клавиши осущ. движение змейки snake.HandleKey(key.Key); } System.Threading.Thread.Sleep(100); snake.Move(); } //Что бы сонсоль закрывалась после нажатия клавиши Console.ReadLine(); }
static void Main(string[] args) { Console.SetWindowSize(1, 1); Console.SetBufferSize(80, 25); Console.SetWindowSize(80, 25); Console.CursorVisible = false; Point p1 = new Point(1, 3, '*'); p1.Draw(); HorizontalLine upLline = new HorizontalLine(0, 78, 0, '+'); HorizontalLine downLline = new HorizontalLine(0, 78, 23, '+'); VerticalLine leftLine = new VerticalLine(0, 24, 0, '+'); VerticalLine rightLine = new VerticalLine(0, 24, 78, '+'); upLline.Draw(); downLline.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, 23, '$'); 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); } Thread.Sleep(100); } }
static void Main(string[] args) { Console.SetWindowSize(150, 40); Console.CursorVisible = false; Console.Title = "Snake"; Console.SetBufferSize(150, 40); HorizontalLine lineTopH = new HorizontalLine(0, 149, 0, '-'); lineTopH.Draw(); HorizontalLine lineDownH = new HorizontalLine(0, 149, 38, '-'); lineDownH.Draw(); VerticalLine lineLeftV = new VerticalLine(1, 37, 0, '#'); lineLeftV.Draw(); VerticalLine lineRightV = new VerticalLine(1, 37, 149, '#'); lineRightV.Draw(); Point p = new Point(5, 7, '*'); 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 (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); } } }
static void Main(string[] args) { Console.SetWindowSize(1, 1); Console.SetBufferSize(80, 25); Console.SetWindowSize(80, 25); //Отрисовка рамки HorizontalLine upline = new HorizontalLine(0, 78, 0, '+'); HorizontalLine downline = new HorizontalLine(0, 78, 24, '+'); VerticalLine leftline = new VerticalLine(0, 24, 0, '+'); VerticalLine rightline = new VerticalLine(0, 24, 78, '+'); rightline.Draw(); upline.Draw(); downline.Draw(); leftline.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); } } // Console.ReadLine(); }
static void Main(string[] args) { /// ----- Lesson 12 ----- /// "Змейка" с хорошим аппетитом /// /* Отрисовка Рамочки */ Console.SetBufferSize(80, 25); // Блокируем окошко HorizontalLine TopLine = new HorizontalLine(0, 78, 0, '+'); // Создание линии HorizontalLine BottomLine = new HorizontalLine(0, 78, 24, '+'); VerticalLine LeftLine = new VerticalLine(0, 24, 0, '+'); VerticalLine RightLine = new VerticalLine(0, 24, 78, '+'); TopLine.Draw(); // Отрисовка линии BottomLine.Draw(); LeftLine.Draw(); RightLine.Draw(); /* Отрисовка змейки */ Point p = new Point(2, 2, '*'); // Стартовая позиция хвоста 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 (snake.Eat(food)) { food = foodCreator.CreateFood(); food.Draw(); } else { snake.Move(); } Thread.Sleep(150); // Считывание с консоли нажатия if (Console.KeyAvailable) { ConsoleKeyInfo key = Console.ReadKey(); snake.HandleKey(key.Key); } } }
static void Main(string[] args) { Console.SetBufferSize(120, 31); HorizontalLine GorizontalLine1 = new HorizontalLine(0, 120, 0, '+'); GorizontalLine1.Draw(); HorizontalLine GorizontalLine2 = new HorizontalLine(0, 120, 29, '+'); GorizontalLine2.Draw(); VerticalLine VerticalLine1 = new VerticalLine(0, 29, 0, '+'); VerticalLine1.Draw(); VerticalLine VerticalLine2 = new VerticalLine(0, 29, 119, '+'); VerticalLine2.Draw(); // точки Point p = new Point(4, 5, '*'); // p.Draw(); Snake snake = new Snake(p, 4, Direction.RIGHT); snake.Draw(); FoodCreator foodCreator = new FoodCreator(120, 31, '$'); 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); } Thread.Sleep(100); snake.Move(); } }
static void Main(string[] args) { Console.CursorVisible = false; Console.SetBufferSize(80, 25); //Рамочки HorizontalLine lineUp = new HorizontalLine(0, 78, 0, '+'); lineUp.Draw(); HorizontalLine lineDown = new HorizontalLine(0, 78, 24, '+'); lineDown.Draw(); VerticalLine lineLeft = new VerticalLine(0, 24, 0, '+'); lineLeft.Draw(); VerticalLine lineRight = new VerticalLine(0, 24, 78, '+'); lineRight.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(200); if (Console.KeyAvailable) { ConsoleKeyInfo key = Console.ReadKey(); snake.HandleKey(key.Key); } } }
public static void DrawField(int width, int heigth) { Console.SetBufferSize(width, heigth); HorizontalLine topLine = new HorizontalLine(0, width - 2, 0, '+'); HorizontalLine bottomLine = new HorizontalLine(0, width - 2, heigth - 1, '+'); VerticalLine leftLine = new VerticalLine(0, heigth - 1, 0, '+'); VerticalLine rightLine = new VerticalLine(0, heigth - 1, width - 2, '+'); topLine.Draw(); bottomLine.Draw(); leftLine.Draw(); rightLine.Draw(); }
public Walls(int w, int h) { Width = w; Heigh = h; HorizontalLine hl1 = new HorizontalLine(0, 0, '/', w); HorizontalLine hl2 = new HorizontalLine(0, h, '/', w); VerticalLine vl1 = new VerticalLine(0, 1, '/', h - 1); VerticalLine vl2 = new VerticalLine(w, 1, '/', h - 1); hl1.Draw(); hl2.Draw(); vl1.Draw(); vl2.Draw(); }
public Walls(int mapWidth, int mapHeight) { wallList = new List <Figure>(); HorizontalLine upLine = new HorizontalLine(0, mapWidth - 2, 0, '+'); upLine.Draw(); HorizontalLine downLine = new HorizontalLine(0, mapWidth - 2, mapHeight - 1, '+'); downLine.Draw(); VerticalLine leftLine = new VerticalLine(0, mapHeight - 1, 0, '+'); leftLine.Draw(); VerticalLine rightLine = new VerticalLine(0, mapHeight - 1, mapWidth - 2, '+'); rightLine.Draw(); }
static void Main(string[] args) { //Point p1 = new Point(1,3,'*'); //p1.Draw(); //Point p2 = new Point(4, 5,'#'); //p2.Draw(); HorizontalLine Line = new HorizontalLine(1, 50, 3, '*'); Line.Draw(); VerticalLine vLine = new VerticalLine(3, 25, 1, '*'); vLine.Draw(); Console.ReadKey(); }
static void Main(string[] args) { //Отрисовка рамок закрепление размера окна Console.SetWindowSize(112, 25); Console.SetBufferSize(112, 25); HorizontalLine upLine = new HorizontalLine(0, 110, 0, '*'); HorizontalLine downLine = new HorizontalLine(0, 110, 24, '*'); VerticalLine vertticalLineRight = new VerticalLine(110, 0, 24, '*'); VerticalLine verticalLineLeft = new VerticalLine(0, 0, 24, '*'); upLine.Draw(); downLine.Draw(); vertticalLineRight.Draw(); verticalLineLeft.Draw(); Console.ReadKey(); }
static void Main(string[] args) { /// ----- Lesson 7 ----- /// Класс "Горизонтальные/Вертикальные линии" /// /* Отрисовка Рамочки */ Console.SetBufferSize(80, 25); // Блокируем окошко HorizontalLine TopLine = new HorizontalLine(0, 78, 0, '+'); // Создание линии HorizontalLine BottomLine = new HorizontalLine(0, 78, 24, '+'); VerticalLine LeftLine = new VerticalLine(0, 24, 0, '+'); VerticalLine RightLine = new VerticalLine(0, 24, 78, '+'); TopLine.Draw(); // Отрисовка линии BottomLine.Draw(); LeftLine.Draw(); RightLine.Draw(); Console.ReadLine(); }
static void Main(string[] args) { Console.SetBufferSize(120, 30); //The frame is drawn HorizontalLine upLine = new HorizontalLine(0, 118, 0, '+'); HorizontalLine downLine = new HorizontalLine(0, 118, 29, '+'); VerticalLine leftLine = new VerticalLine(0, 29, 0, '+'); VerticalLine rightLine = new VerticalLine(0, 29, 118, '+'); upLine.Draw(); downLine.Draw(); leftLine.Draw(); rightLine.Draw(); //The points are drawn Point p = new Point(4, 5, '*'); Snake snake = new Snake(p, 4, Direction.RIGHT); snake.Draw(); FoodCreator foodCreator = new FoodCreator(129, 30, '$'); 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.HandlKey(key.Key); } } }
static void Main(string[] args) { Console.SetBufferSize(120, 80); HorizontalLine lineTop = new HorizontalLine(1, 88, 0, '@'); lineTop.Draw(); HorizontalLine lineBottom = new HorizontalLine(1, 88, 22, '@'); lineBottom.Draw(); VerticalLine lineLeft = new VerticalLine(0, 22, 0, '@'); lineLeft.Draw(); VerticalLine lineRight = new VerticalLine(0, 22, 88, '@'); lineRight.Draw(); Point p = new Point(8, 8, '*'); p.Draw(); //snake Snake snake = new Snake(p, 4, Direction.RIGHT); snake.Draw(); snake.Move(); Thread.Sleep(300); snake.Move(); Thread.Sleep(300); snake.Move(); Thread.Sleep(300); snake.Move(); Thread.Sleep(300); snake.Move(); Thread.Sleep(300); snake.Move(); Thread.Sleep(300); snake.Move(); Thread.Sleep(300); snake.Move(); Thread.Sleep(300); }
public Walls(int mapWidht, int mapHeight) { WallList = new List <Figure>(); HorizontalLine Upline = new HorizontalLine(0, mapWidht - 2, 0, '+'); HorizontalLine Downline = new HorizontalLine(0, mapWidht - 2, mapHeight - 1, '+'); VerticalLine Leftline = new VerticalLine(0, mapHeight - 1, 0, '+'); VerticalLine Rightline = new VerticalLine(0, mapHeight - 1, mapWidht - 2, '+'); WallList.Add(Upline); WallList.Add(Downline); WallList.Add(Leftline); WallList.Add(Rightline); Upline.Draw(); Downline.Draw(); Leftline.Draw(); Rightline.Draw(); }
static void Main(string[] args) { Point p1 = new Point(1, 3, '*'); p1.Draw(); Point p2 = new Point(4, 5, '#'); p2.Draw(); HorizontalLine line = new HorizontalLine(5, 10, 8, '+'); line.Draw(); VerticalLine lineY = new VerticalLine(2, 5, 3, '*'); lineY.Draw(); Console.ReadLine(); }
static void Main(string[] args) { Console.SetWindowSize(1, 1); Console.SetBufferSize(80, 25); Console.SetWindowSize(80, 25); VerticalLine leftline = new VerticalLine(0, 24, 0, '+'); VerticalLine rightline = new VerticalLine(0, 24, 78, '+'); HorizontalLine upline = new HorizontalLine(0, 78, 0, '+'); HorizontalLine downline = new HorizontalLine(0, 78, 24, '+'); upline.Draw(); downline.Draw(); leftline.Draw(); rightline.Draw(); Point p = new Point(20, 20, '*'); p.Draw(); Console.ReadLine(); }
private static void Main(string[] args) { Console.SetWindowPosition(0, 0); 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, 24, 0, '+'); VerticalLine rightLine = new VerticalLine(0, 24, 78, '+'); upLine.Draw(); downLine.Draw(); leftLine.Draw(); rightLine.Draw(); Point p = new Point(4, 5, '*'); p.Draw(); Console.ReadKey(); }
static void Main(string[] args) { List <char> chList = new List <char>(); chList.Add('*'); chList.Add('#'); chList.Add('@'); chList.Add('%'); Point p1 = new Point(1, 3, chList[0]); Point p2 = new Point(4, 6, chList[1]); Point p3 = new Point(8, 10, chList[2]); Point p4 = new Point(7, 6, chList[3]); List <Point> pList = new List <Point>(); pList.Add(p1); pList.Add(p2); pList.Add(p3); pList.Add(p4); foreach (Point i in pList) { i.Draw(); } HorizontalLine line = new HorizontalLine(5, 10, 8, '+'); line.Draw(); VerticalLine vline = new VerticalLine(5, 10, 15, '$'); vline.Draw(); Console.ReadLine(); }
static void Main(string[] args) { Console.SetBufferSize(80, 25); HorizontalLine upLine = new HorizontalLine(0, 78, 0, '+'); HorizontalLine downLine = new HorizontalLine(0, 78, 24, '+'); VerticalLine leftLine = new VerticalLine(0, 24, 0, '+'); VerticalLine rightLine = new VerticalLine(0, 24, 78, '+'); upLine.Draw(); downLine.Draw(); leftLine.Draw(); rightLine.Draw(); Point p1 = new Point(10, 10, '*'); Snake snake = new Snake(p1, 4, Direction.UP); snake.Draw(); while (true) { if (Console.KeyAvailable) { ConsoleKeyInfo key = Console.ReadKey(); snake.HandleKey(key.Key); } Thread.Sleep(100); snake.Move(); } Console.ReadLine(); }
static void Main(string[] args) { /// ----- Lesson 9 ----- /// Принцип ООП: Абстрагирование. Класс "Змейка" /// /* Отрисовка Рамочки */ Console.SetBufferSize(80, 25); // Блокируем окошко HorizontalLine TopLine = new HorizontalLine(0, 78, 0, '+'); // Создание линии HorizontalLine BottomLine = new HorizontalLine(0, 78, 24, '+'); VerticalLine LeftLine = new VerticalLine(0, 24, 0, '+'); VerticalLine RightLine = new VerticalLine(0, 24, 78, '+'); TopLine.Draw(); // Отрисовка линии BottomLine.Draw(); LeftLine.Draw(); RightLine.Draw(); /* Отрисовка змейки */ Point p = new Point(2, 2, '*'); Snake snake = new Snake(p, 5, Direction.RIGHT); snake.Draw(); Console.ReadLine(); }