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) { Point p1 = new Point(1, 3, '*'); p1.Draw(); Point p2 = new Point(10, 3, '#'); p2.Draw(); List<char> List1 = new List<char>(); List1.Add('A'); List1.Add('#'); foreach (char i in List1) { Console.WriteLine(i); } List<Point> Blabla = new List<Point>(); Blabla.Add( p1 ); Blabla.Add( p2 ); foreach (Point z in Blabla) { Console.WriteLine(z); } Console.ReadLine(); }
static void Main(string[] args) { Point p1 = new Point(1, 3, '*'); p1.Draw(); Point p2 = new Point(4, 5, '#'); p2.Draw(); List<int> numList = new List<int>(); numList.Add(7); numList.Add(2); numList.Add(5); int x = numList[0]; int y = numList[1]; int z = numList[2]; foreach(int i in numList) { Console.WriteLine(i); } numList.RemoveAt(0); List<Point> pList = new List<Point>(); pList.Add(p1); pList.Add(p2); Console.ReadLine(); }
static void Main(string[] args) { Point p1 = new Point(1, 3, '*'); p1.Draw(); Point p2 = new Point(4, 5, '#'); p2.Draw(); Console.ReadLine(); }
public void Move() { Point tail = pList.First(); Point head = pList.Last(); Point NextPoint = new Point(head); tail.Clear(); pList.Remove(tail); NextPoint.Move(1, direction); NextPoint.Draw(); pList.Add(NextPoint); }
internal bool Eat(Point food) { Point head = getNextPoint (); if(head.IsHit(food)){ food.sym = head.sym; food.Draw (); pList.Add (food); return true; } else return false; }
static void Main(string[] args) { Point p1 = new Point(1,3,'*'); p1.Draw(); Point p2 = new Point(); p2.x = 4; p2.y = 5; p2.sym = '#'; p2.Draw(); Console.ReadLine(); }
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(); }
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 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(); }
static void Main( string [] args) { Point p1=new Point(); p1.x=1; p1.y=3; p1.sym='*'; p1.Draw() Point p1=new Point(); p2.x=4; p2.y=5; p2.sym='#'; p2.Draw() Console.SetCursorPosition(x2,y2); Console.Write(sym2); Console.ReadLine(); }
static void Main(string[] args) { //вместо нижеописанного задействуем класс point Point p1 = new Point();//создаем экземпляр класса(объект) p1.x = 1; p1.y = 3; p1.sym = '*'; //Draw(p1.x, p1.y, p1.sym); вместо этого, можно в классе указать работу с функцией p1.Draw(); /* int x1 = 1; int y1 = 3; char sym1 = '*'; Draw(x1, y1, sym1);//теперь мы можем использовать функцию */ //Console.SetCursorPosition(x1, y1);//установить курсор на позицию //Console.Write(sym1); //аналогично делаем со второй точкой Point p2 = new Point(); p2.x = 4; p2.y = 5; p2.sym = '#'; Draw(p2.x, p2.y, p2.sym); /*int x2 = 4; int y2 = 5; char sym2 = '#'; Draw(x2, y2, sym2); */ //Console.SetCursorPosition(x2, y2);//установить курсор на позицию //Write(sym2); Console.ReadLine(); }
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(); }
private void Game_Draw(Graphics g) { g.DrawRectangle(Pens.Black, 0, 0, MapWidth * Size, MapHeight * Size); Head.Draw(g); }
static void Main(string[] args) { Console.SetWindowSize(79, 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(75, 25, '%', '#', '@'); Point food = foodCreator.CreateFood(); Point spsfood = foodCreator.CreateSpsFood(); Point badfood = foodCreator.CreateBadFood(); food.Draw(); int score = 0; Params settings = new Params(); Sounds sound = new Sounds(settings.GetResourcesFolder()); sound.Play(); Sounds soundEat = new Sounds(settings.GetResourcesFolder()); while (true) { if (walls.IsHit(snake) || snake.IsHitTail()) { break; } if (snake.Eat(food)) { food = foodCreator.CreateFood(); food.Draw(); score++; soundEat.EatPlay(); if (score > 2) { spsfood = foodCreator.CreateSpsFood(); spsfood.Draw(); badfood = foodCreator.CreateBadFood(); badfood.Draw(); } } Colors col = new Colors(score); Speed spe = new Speed(score); if (snake.Eat(spsfood)) { score += 4; soundEat.PlaySpsEat(); } if (snake.Eat(badfood)) { score -= 4; soundEat.PlayBadEat(); } else { snake.Move(); Thread.Sleep(100); } if (Console.KeyAvailable) { ConsoleKeyInfo key = Console.ReadKey(); snake.HandleKey(key.Key); } } sound.PlayStop(); TotalScore(score); Leader name = new Leader(score); }
// Проверяем столкнулся ли с объектом public void Eat() { Point head = new Point(GetNextPoint()); pList.Add(head); head.Draw(); }
static void Main(string[] args) { Console.SetWindowSize(102, 30); string name; while (true) { Console.Write("Введите свое имя: "); name = Console.ReadLine(); if (name.Length < 3) { Console.Clear(); Console.WriteLine("Имя должно быть больше 3 символа."); continue; } else if (name.Length > 8) { Console.Clear(); Console.WriteLine("Имя не должно быть больше 8 символов."); continue; } else { Console.Clear(); break; } } Music music = new Music(); music.MainMusic(); Walls walls = new Walls(100, 25); walls.Draw(); Point p = new Point(4, 5, '*'); Snake snake = new Snake(p, 4, Direction.RIGHT); snake.Draw(); FoodCreator foodCreator = new FoodCreator(100, 24); Point food = foodCreator.CreateFood(); food.Draw(); Text text = new Text(); int xOffsetO4ki = 40; int yOffsetO4ki = 26; int size = 4; text.WriteText("Длина змеи:" + size, xOffsetO4ki - 35, yOffsetO4ki); int o4ki = 0; text.WriteText("Баллы:" + o4ki, xOffsetO4ki, yOffsetO4ki); Stopwatch stopWatch = new Stopwatch(); // секундомер stopWatch.Start(); // запустить секундомер while (true) { Console.SetCursorPosition(xOffsetO4ki, 27); TimeSpan ts = stopWatch.Elapsed; // структура для работы с временем Console.WriteLine($"{ts.Minutes:00}:{ts.Seconds:00}"); // вывод секунд и минут if (walls.IsHit(snake) || snake.IsHitTail()) { stopWatch.Stop(); break; } if (snake.Eat(food)) { music.EatSound(); FoodCreator food1 = new FoodCreator(100, 24); food = food1.CreateFood(); food.FoodDraw(); o4ki++; Console.SetCursorPosition(xOffsetO4ki, yOffsetO4ki); text.WriteText("Баллы:" + o4ki, xOffsetO4ki, yOffsetO4ki); size++; Console.SetCursorPosition(xOffsetO4ki, yOffsetO4ki); text.WriteText("Длина змеи:" + size, xOffsetO4ki - 35, yOffsetO4ki); } else { snake.Move(); } Thread.Sleep(100); if (Console.KeyAvailable) { ConsoleKeyInfo key = Console.ReadKey(); snake.HandleKey(key.Key); } } Console.WriteLine(stopWatch.ElapsedTicks); var time = stopWatch.Elapsed; music.GameOver(); GameOver game = new GameOver(); game.WriteGameOver(o4ki); SaveFiles saveFiles = new SaveFiles(); saveFiles.to_file(name, o4ki, size, time); ConsoleKeyInfo btn = Console.ReadKey(); if (btn.Key == ConsoleKey.Enter) { var fileName = Assembly.GetExecutingAssembly().Location; System.Diagnostics.Process.Start(fileName); Environment.Exit(0); } }
static void Main() { var p = new Point{Img = '#', X = 2, Y = 5}; p.Draw(); }
static void Main(string[] args) { Console.SetWindowSize(85, 35); 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, '#', '0', '+'); Point food = foodCreator.CreateFood(); Point Sfood = foodCreator.CreateFoodS(); Point Bfood = foodCreator.CreateFoodB(); food.Draw(); Parametrs settings = new Parametrs(); Sounds sound = new Sounds(settings.GetResourceFolder()); sound.Play(); Sounds sound1 = new Sounds(settings.GetResourceFolder()); Sounds soundS = new Sounds(settings.GetResourceFolder()); Sounds soundB = new Sounds(settings.GetResourceFolder()); Score score = new Score(settings.GetResourceFolder()); while (true) { if (walls.IsHit(snake) || snake.IsHitTail()) { Console.Beep(300, 500); Thread.Sleep(50); Console.Beep(300, 500); Thread.Sleep(50); Console.Beep(300, 500); Thread.Sleep(50); Console.Beep(250, 500); Thread.Sleep(50); Console.Beep(350, 250); Console.Beep(300, 500); Thread.Sleep(50); Console.Beep(250, 500); Thread.Sleep(50); Console.Beep(350, 250); Console.Beep(300, 500); Thread.Sleep(50); break; } if (snake.Eat(food)) { food = foodCreator.CreateFood(); food.Draw(); sound1.PlayEat(); score.UpCurrentPoints(); score.ShowCurrentPoints(); if (score.ShowPoint() % 50 == 0) { Sfood = foodCreator.CreateFoodS(); Sfood.Draw(); Bfood = foodCreator.CreateFoodB(); Bfood.Draw(); } } if (snake.Eat(Sfood)) { score.UpPoinS(); score.ShowCurrentPoints(); soundS.PlayEatS(); } if (snake.Eat(Bfood)) { score.DownPointB(); score.ShowCurrentPoints(); soundB.PlayEatB(); } else { snake.Move(); } Thread.Sleep(200); if (Console.KeyAvailable) { ConsoleKeyInfo key = Console.ReadKey(); snake.HandleKey(key.Key); } } score.WriteGameOver(); }