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) { //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) { var x = Console.WindowWidth; //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.DrawLine(); downLine.DrawLine(); leftLine.DrawLine(); rightLine.DrawLine(); Point p = new Point(4, 5, '*'); Snake snake = new Snake(p, 4, Direction.RIGHT); snake.DrawLine(); while (true) { if(Console.KeyAvailable) { ConsoleKeyInfo key = Console.ReadKey(); snake.HandleKey(key.Key); } Thread.Sleep(100); snake.Move(); } Console.ReadKey(); }
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(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(); }
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); }
public Walls(int w, int h) { wallList = new List<Figure>(); HorizontalLine upLine = new HorizontalLine(0, w -2, 0, '+'); HorizontalLine downLine = new HorizontalLine(0, w -2, h-1, '+'); VerticalLine leftLine = new VerticalLine(0, h-1, 0, '+'); VerticalLine rightLine = new VerticalLine(0, h-1, w-2, '+'); wallList.Add( upLine); wallList.Add(downLine); wallList.Add(leftLine); wallList.Add(rightLine); }
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.Drow(); Console.ReadLine(); }
public Walls(int mapWidht, int mapHeight) { WallList = new List<Figure>(); HorizontalLine TopLine = new HorizontalLine(0, mapWidht-2, 0, '+'); HorizontalLine BotLine = 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(TopLine); WallList.Add(BotLine); WallList.Add(LeftLine); WallList.Add(RightLine); }
public Walls(int mapWidth, int mapHeight) { wallList = new List<Figure>(); HorizontalLine horLine = new HorizontalLine(0, mapWidth - 2, 0, '+',ColorSnake.WHITE); HorizontalLine botLine = new HorizontalLine( 0, mapWidth - 2,mapHeight - 1, '+',ColorSnake.WHITE); VerticalLine leftLine = new VerticalLine(0, mapHeight - 1, 0, '+',ColorSnake.WHITE); VerticalLine rightLine = new VerticalLine(0, mapHeight - 1, mapWidth - 2, '+',ColorSnake.WHITE); wallList.Add(horLine); wallList.Add(botLine); wallList.Add(leftLine); wallList.Add(rightLine); }
public Walls(int mapWidth, int mapHeight) { wList = new List<Figure>(); HorizontalLine hLineTop = new HorizontalLine(0, mapWidth-2, 0, '+'); HorizontalLine hLineDown = new HorizontalLine(0, mapWidth-2, mapHeight-1, '+'); VerticalLine vLineLeft = new VerticalLine(0, mapHeight-1, 0, '+'); VerticalLine vLineRight = new VerticalLine(0, mapHeight-1, mapWidth-2, '+'); wList.Add(hLineTop); wList.Add(hLineDown); wList.Add(vLineLeft); wList.Add(vLineRight); }
public Wall(int maxWeight, int maxHeight, char sym) { figurelist = new List<Figure>(); HorizontalLine topWall = new HorizontalLine(0, maxWeight - 2, 0, sym); HorizontalLine downWall = new HorizontalLine(0, maxWeight - 2, maxHeight - 1, sym); VerticalLine leftWall = new VerticalLine(0, maxHeight - 1, 0, sym); VerticalLine rightWall = new VerticalLine(0, maxHeight - 1, maxWeight - 2, sym); figurelist.Add(topWall); figurelist.Add(downWall); figurelist.Add(leftWall); figurelist.Add(rightWall); }
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.SetBufferSize(80, 25); Point p1 = new Point(10,20,'*'); p1.Draw(); HorizontalLine Upline = new HorizontalLine(0, 78, 0, '+'); VerticalLine LeftLine = new VerticalLine(0, 24, 0, '+'); HorizontalLine Downline = new HorizontalLine(0, 78, 24, '+'); VerticalLine Rightline = new VerticalLine(0, 24, 78, '+'); Upline.Drow(); LeftLine.Drow(); Rightline.Drow(); Downline.Drow(); 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.Drow(); downLine.Drow(); leftLine.Drow(); rightLine.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.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.SetBufferSize(80,25); //Отрисовка рамки HorizontalLine upLine = new HorizontalLine(0,78, 0 , '+'); HorizontalLine downLine = new HorizontalLine(0,78, 24 , '+'); VerticalLine leftLine = new HorizontalLine(0,24, 0 , '+'); VerticalLine rightLine = new HorizontalLine(0,24, 78 , '+'); upLine.Drow(); downLine.Drow(); leftLine.Drow(); rightLine.Drow(); //Отрисовка точек Point p = new Point(4,5,'*'); p.Draw(); }
public Walls(char sym) { gameObjects = new List<Figure>(); this.width = Console.BufferWidth; this.height = Console.BufferHeight; HorizontalLine upLine = new HorizontalLine(0, this.width - 2, 0, sym); HorizontalLine downLine = new HorizontalLine(0, this.width - 2, this.height - 1, sym); VerticalLine leftLine = new VerticalLine(0, 0, this.height - 1, sym); VerticalLine rigthLine = new VerticalLine(this.width - 2, 0, this.height - 1, sym); gameObjects.Add(upLine); gameObjects.Add(downLine); gameObjects.Add(leftLine); gameObjects.Add(rigthLine); Draw(); }
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); } } }
public Walls(int mapWidth, int mapHeight) { wallsList = new List<Figure>(); HorizontalLine downHorizontalLine = new HorizontalLine(0, mapWidth - 1, mapHeight - 1, '+'); // Down horizontal line (xLeft, xRight, y, symbol) // downHorizontalLine.DrawFigure(); wallsList.Add(downHorizontalLine); HorizontalLine upHorizontalLine = new HorizontalLine(0, mapWidth - 1 , 0, '+'); // Up horizontal line (xLeft, xRight, y, symbol) // upHorizontalLine.DrawFigure(); wallsList.Add(upHorizontalLine); VerticalLine leftVerticalLine = new VerticalLine(0, mapHeight - 1, 0, '+'); // Left vertical line (yUp, yDown, x, symbol) //leftVerticalLine.DrawFigure(); wallsList.Add(leftVerticalLine); VerticalLine rightVerticalLine = new VerticalLine(0, mapHeight - 1, mapWidth - 1, '+'); // Right vertical line (yUp, yDown, x, symbol) // rightVerticalLine.DrawFigure(); wallsList.Add(rightVerticalLine); }
static void Main(string[] args) { 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.LineDraw(); bottomLine.LineDraw(); leftLine.LineDraw(); rightLine.LineDraw(); Point p = new Point(4, 5, '*'); Snake snake = new Snake(p, 4, Direction.RIGHT); snake.LineDraw(); Console.ReadLine(); }
public void EndGame() { HorizontalLine endGameTop = new HorizontalLine (Console.BufferWidth / 4, Console.BufferWidth * 3 / 4, Console.BufferHeight / 2 - 2, '='); endGameTop.Draw(); string endGameText = "G A M E O V E R"; Credits(endGameText, Console.BufferWidth / 2 - endGameText.Length / 2, Console.BufferHeight / 2 - 1); string endGameAuthorText = "Author: Remizov Pavel"; Credits(endGameAuthorText, Console.BufferWidth / 2 - endGameAuthorText.Length / 2, Console.BufferHeight / 2); string endGameSpecialThanksText = "Special thanks to GeekBrains"; Credits(endGameSpecialThanksText, Console.BufferWidth / 2 - endGameSpecialThanksText.Length / 2, Console.BufferHeight / 2 + 1); string endGameExtra = "Student speciality: C# Developer"; Credits(endGameExtra, Console.BufferWidth / 2 - endGameExtra.Length / 2, Console.BufferHeight / 2 + 2); HorizontalLine endGameBottom = new HorizontalLine (Console.BufferWidth / 4, Console.BufferWidth * 3 / 4, Console.BufferHeight / 2 + 3, '='); endGameBottom.Draw(); }
static void Main(string[] args) { /*int x1 = 5; int y1 = 5; char sym1 = '*'; int x2 = 10; int y2 = 10; char sym2 = '#'; Draw(x1, y1, sym1); Draw(x2, y2, sym2); Console.ReadKey(); } static void Draw(int x, int y, char sym) { Console.SetCursorPosition(x, y); Console.WriteLine(sym); }*/ Point p1 = new Point(5,5,'$'); Point p2 = new Point(10,10,'%'); p1.Draw(); p2.Draw(); HorizontalLine hLine = new HorizontalLine(5, 10, 8, '+'); VericalLine vLine = new VericalLine(5, 5, 15, '+'); hLine.pDraw(); vLine.pDraw(); Console.ReadKey(); }
static void Main(string[] args) { /// ----- Lesson 11 ----- /// Управляемая "Змейка" /// /* Отрисовка Рамочки */ 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(); // Отрисовать змейку /* Управление змейкой */ while (true) { if (Console.KeyAvailable) { ConsoleKeyInfo key = Console.ReadKey(); snake.HandleKey(key.Key); } Thread.Sleep(150); 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(); 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) { Console.SetBufferSize(120, 30); HorizontalLine hLine1 = new HorizontalLine(0, 78, 0, '#'); HorizontalLine hLine2 = new HorizontalLine(0, 78, 24, '#'); hLine1.Drow(); hLine2.Drow(); VerticalLine vLine1 = new VerticalLine(0, 24, 0, '#'); VerticalLine vLine2 = new VerticalLine(0, 24, 78, '#'); vLine1.Drow(); vLine2.Drow(); Point p = new Point(4, 5, '*'); Snake snake = new Snake(p, 4, Direction.RIGHT); snake.Drow(); 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(); }
static void Main(string[] args) { Console.SetWindowSize(80, 26); Console.SetBufferSize(80, 26); 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.Drow(); downLine.Drow(); leftLine.Drow(); rightLine.Drow(); Point p = new Point(4, 5, '*'); Snake snake = new Snake(p, 4, Direction.RIGHT ); snake.Drow(); while (true) { //лень пилить } }
static void Main(string[] args) { Console.SetWindowSize(1, 1); Console.SetBufferSize(80, 25); Console.SetWindowSize(80, 25); var walls = new Walls(80, 25); walls.Draw(); //Отрисовка рамки var upLine = new HorizontalLine(0, 78, 0, '+'); var downLine = new HorizontalLine(0, 78, 24, '+'); var liftLine = new VerticalLine(0, 24, 0, '+'); var rightLine = new VerticalLine(0, 24, 78, '+'); upLine.Draw(); downLine.Draw(); liftLine.Draw(); rightLine.Draw(); //Отрисовка точек var p = new Point(4, 5, '*'); var snake = new Snake(p, 4, Direction.RIGTH); snake.Draw(); var foodCreator = new FoodCreator(80, 25, '$'); var 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.Heandl(key.Key); } Thread.Sleep(100); //snake.Move(); } //Console.ReadLine(); }
static void Main(string[] args) { Console.SetWindowSize(80, 25); Console.SetBufferSize(80, 25); //XSTEP 5 Class Figure //STEP 4 Horizontal line HorizontalLine topLine = new HorizontalLine(0, 78, 0, '*'); //topLine.DrawHrLine(); topLine.DrawFigure(); HorizontalLine bottomLine = new HorizontalLine(0, 78, 24, '*'); //bottomLine.DrawHrLine(); bottomLine.DrawFigure(); VerticalLine leftLine = new VerticalLine(0, 24, 0, '*'); //leftLine.DrawVerticalLine(); leftLine.DrawFigure(); VerticalLine rightLine = new VerticalLine(0, 24, 78, '*'); //rightLine.DrawVerticalLine(); rightLine.DrawFigure(); //STEP 6 Snake Point p1 = new Point(6, 5, '*'); Snake snake = new Snake(p1, 4, Direction.RIGHT); snake.DrawFigure(); snake.Move(); Thread.Sleep(300); snake.Move(); Thread.Sleep(300); snake.Move(); Thread.Sleep(300); snake.Move(); Thread.Sleep(300); snake.Move(); //STEP 5 Vertical line /* VerticalLine vLine = new VerticalLine(0, 23, 5, '*'); * vLine.DrawVerticalLine();*/ //STEP3 /* Point p1 = new Point(0, 5, '*'); * p1.Draw();*/ //STEP2 /*int x1 = 0; * int y1 = 0; * char sym1 = '#'; * * Draw(x1, y1, sym1);*/ //STEP1 /*int x1 = 1; * int y1 = 3; * char sym1 = '*'; * * Console.SetCursorPosition(x1, y1); * Console.Write(sym1); * * int x2 = 0; * int y2 = 0; * char sym2 = '#'; * Console.SetCursorPosition(x2, y2); * Console.Write(sym2);*/ Console.ReadLine(); }