static void Main(string[] args) { Console.SetBufferSize(88, 25); //Отрисовка стен - рамочки Walls walls = new Walls(88, 25); walls.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 (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); // изменяем направление змейки } } //Чтобы не отображался курсор Console.CursorVisible = false; }
static void Main(string[] args) { // создаем границы консоли Arkasha Console.SetBufferSize(80, 25); Walls walls = new Walls(80, 25); walls.Draw(); //отрисовка точек Point p = new Point(10, 10, '*'); Snake snake = new Snake(p, 3, 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(); }
static void Main(string[] args) { Console.SetWindowSize(80, 25); Console.SetBufferSize(80, 25); Console.CursorVisible = false; Walls walls = new Walls(80, 25); walls.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 (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); } } }
static void Main(string[] args) { Console.SetWindowSize(1, 1); Console.SetBufferSize(80, 25); Console.SetWindowSize(80, 25); HorisontalLine upline = new HorisontalLine(0, 78, 0, '+'); VerticalLine rigthline = new VerticalLine(0, 0, 24, '+'); HorisontalLine downline = new HorisontalLine(0, 78, 24, '+'); VerticalLine leftline = new VerticalLine(78, 0, 24, '+'); upline.Draw(); rigthline.Draw(); downline.Draw(); leftline.Draw(); Point p = new Point(4, 5, '*'); Snake snake = new Snake(p, 3, Direction.RIGTH); snake.Draw(); FoodCreator foodCreator = new FoodCreator(80, 25, '#'); Point food = foodCreator.CreateFood(); food.Drow(); while (true) { if (snake.Eat(food)) { food = foodCreator.CreateFood(); food.Drow(); } else { snake.Move(); } if (Console.KeyAvailable) { ConsoleKeyInfo key = Console.ReadKey(); snake.directionOfMovement(key.Key); } Thread.Sleep(300); snake.Move(); } }
static void Main(string[] args) { Console.SetBufferSize(120, 30); Walls walls = new Walls(120, 30); walls.Draw(); //Отрисовка точек point p = new point(4, 5, '*'); Snake snake = new Snake(p, 4, Direction.right); snake.Draw(); FoodCreator foodCreator = new FoodCreator(120, 30, '$'); 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(); }
static void Main(string[] args) { Console.SetBufferSize(80,25); //установить размер окна и убрать возможность перемотки Walls walls = new Walls(80, 25); walls.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 (walls.IsHit(snake) || snake.IsHitTail()) { Console.Clear(); Console.SetCursorPosition(37, 7); Console.Write("YOU LOSE"); 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); } } Console.ReadKey(); }
static void Main(string[] args) { Console.SetBufferSize(120, 30); Wall walls = new Wall(120, 30); walls.Draw(); Point p = new Point(50, 10, '*'); Snake snake = new Snake(p, 4, Direction.left); snake.Draw(); FoodCreator foodCreator = new FoodCreator(120, 30, 'o'); 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(); } if (Console.KeyAvailable) { ConsoleKeyInfo key = Console.ReadKey(); snake.HandleKey(key); } Thread.Sleep(400); snake.Move(); } }
public static void Main(string[] args) { // Отрисовка рамочки HorizontalLine upLine = new HorizontalLine(0, 150, 0, '+'); HorizontalLine downLine = new HorizontalLine(0, 150, 15, '+'); VerticalLine leftLine = new VerticalLine(0, 15, 0, '+'); VerticalLine rightLine = new VerticalLine(0, 15, 150, '+'); // upLine.Draw(); // downLine.Draw(); // leftLine.Draw(); // rightLine.Draw(); // Отрисовка точек Point p = new Point(5, 4, '*'); Snake snake = new Snake(p, 3, 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.SetBufferSize(60, 20); Walls walls = new Walls(60, 20); walls.Draw(); //отрисовка точек Point p = new Point(4, 5, '*'); Snake snake = new Snake(p, 4, Direction.Right); snake.Draw(); FoodCreator foodCreator = new FoodCreator(60, 20, '$'); Point food = foodCreator.CreateFood(); food.Draw(); while (true) { if (walls.IsHit(snake) || snake.IsHitTail()) { break; } else 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(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, '*'); 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(); } //if (Console.KeyAvailable) //{ // ConsoleKeyInfo key = Console.ReadKey(); // snake.HandleKey(key.Key); //} Thread.Sleep(300); //snake.Move(); } }
static void Main(string[] args) { Console.SetBufferSize(80, 25); Walls walls = new Walls(80, 25); walls.Drow(); //Отрисовка точек Point p = new Point(4, 5, '*'); Snake snake = new Snake(p, 4, Direction.RIGHT); snake.Drow(); FoodCreator foodCreator = new FoodCreator(80, 25, '$'); Point food = foodCreator.CreateFood(); food.Drow(); while (true) { if (walls.IsHit(snake) || snake.IsHitTail()) { break; } if (snake.Eat(food)) { food = foodCreator.CreateFood(); food.Drow(); } else { snake.Move(); } Thread.Sleep(100); if (Console.KeyAvailable) { ConsoleKeyInfo key = Console.ReadKey(); snake.HandleKey(key.Key); } } }
static void Main(string[] args) { Walls walls = new Walls(80, 25); walls.Draw(); //рисуем точки Point p = new Point(4, 5, '*'); Snake snake = new Snake(p, 4, Direction.RIGHT); snake.Draw(); FoodCreator foodcreat = new FoodCreator(80, 25, '&'); Point food = foodcreat.CreateFood(); food.Draw(); while (true) { if (walls.IsHit(snake) || snake.IsHitTail()) { break; } if (snake.Eat(food)) { food = foodcreat.CreateFood(); food.Draw(); } else { snake.Move(); } if (Console.KeyAvailable) { ConsoleKeyInfo key = Console.ReadKey(); snake.Go(key.Key); } Thread.Sleep(100); snake.Move(); } }
static void Main(string[] args) { int choise; int mode; int speed; menu: Console.Clear(); Console.WriteLine("\t$ ЗМЕЙКА ВОЛКОВА $\t telegram автора: serega_vlk\n\n"); Console.WriteLine("1. играть"); Console.WriteLine("2. выход"); choise = Convert.ToInt32(Console.ReadLine()); if (choise == 1) { menu1: Console.Clear(); Console.WriteLine("\t$ ЗМЕЙКА ВОЛКОВА $\t telegram автора: serega_vlk\n\n"); Console.WriteLine("Выберите сложность\n"); Console.WriteLine("1. Тренировка"); Console.WriteLine("2. Арена"); Console.WriteLine("3. Назад"); choise = Convert.ToInt32(Console.ReadLine()); if (choise == 1) { Console.Clear(); mode = 1; } else if (choise == 2) { Console.Clear(); mode = 2; } else if (choise == 3) { Console.Clear(); goto menu; } else { Console.Clear(); goto menu1; } menu2: Console.Clear(); Console.WriteLine("\t$ ЗМЕЙКА ВОЛКОВА $\t telegram автора: serega_vlk\n\n"); Console.WriteLine("Выберите скорость\n"); Console.WriteLine("1. Легкая - 130"); Console.WriteLine("2. Средняя - 100"); Console.WriteLine("3. Сложная - 70"); Console.WriteLine("4. Хардкор - 40"); Console.WriteLine("5. Назад"); choise = Convert.ToInt32(Console.ReadLine()); if (choise == 1) { Console.Clear(); speed = 130; goto start; } else if (choise == 2) { Console.Clear(); speed = 100; goto start; } else if (choise == 3) { Console.Clear(); speed = 70; goto start; } else if (choise == 4) { Console.Clear(); speed = 40; goto start; } else if (choise == 5) { Console.Clear(); goto menu1; } else { Console.Clear(); goto menu2; } } else if (choise == 2) { return; } else { Console.Clear(); goto menu; } start: int weight = 80; int height = 25; Wall frames = new Wall(weight, height); frames.Draw(); Point p = new Point(5, 4, '#'); Snake snake = new Snake(p, 4, Direction.RIGHT); snake.Draw(); FoodCreator foodcreator = new FoodCreator(weight, height, '%'); Point food = foodcreator.CreateFood(); food.Draw(); Console.SetCursorPosition(90, 0); Console.Write("Для выхода нажмите esc"); Console.SetCursorPosition(90, 2); Console.Write("Сложность: " + mode); Console.SetCursorPosition(90, 3); Console.Write("Скорость: " + speed); int counter = 0; bool check = true; while (true) { if (snake.SnakeLenght() && check && mode == 2) { weight = weight - 4; height = height - 1; Console.Clear(); foodcreator = new FoodCreator(weight - 5, height - 2, '%'); frames = new Wall(weight, height); frames.Draw(); food.Draw(); snake.Draw(); Console.SetCursorPosition(90, 0); Console.Write("Для выхода нажмите esc"); Console.SetCursorPosition(90, 2); Console.Write("Сложность: " + mode); Console.SetCursorPosition(90, 3); Console.Write("Скорость: " + speed); check = false; } if (frames.IsHit(snake) || snake.IsHitTail()) { Console.SetCursorPosition(90, 15); Console.Write("Вы проиграли((("); Console.SetCursorPosition(90, 17); Console.Write("Ваш счет: " + Convert.ToString(counter)); Console.SetCursorPosition(90, 19); Console.Write("Нажмите esc для выхода в меню"); while (true) { ConsoleKeyInfo key1 = Console.ReadKey(); if (key1.Key == ConsoleKey.Escape) { break; } } goto menu; } if (snake.Eat(food)) { counter++; while (true) { food = foodcreator.CreateFood(); if (snake.IsHitPoint(food)) { continue; } else { break; } } food.Draw(); check = true; } else { snake.Move(); } Thread.Sleep(speed); if (Console.KeyAvailable) { ConsoleKeyInfo key = Console.ReadKey(); if (key.Key == ConsoleKey.LeftArrow) { snake.direction = Direction.LEFT; } else if (key.Key == ConsoleKey.RightArrow) { snake.direction = Direction.RIGHT; } else if (key.Key == ConsoleKey.UpArrow) { snake.direction = Direction.UP; } else if (key.Key == ConsoleKey.DownArrow) { snake.direction = Direction.DOWN; } else if (key.Key == ConsoleKey.Escape) { Console.Clear(); Console.SetCursorPosition(0, 0); goto menu; } } } }