public Game() { Console.SetWindowSize(100, 30); Walls walls = new Walls(80, 25); walls.Draw(); Point p = new Point(4, 5, 'x'); Snake snake = new Snake(p, 4, Direction.RIGHT); snake.Draw(); FoodCreator foodCreator = new FoodCreator(80, 25, 'o'); Point food = foodCreator.CreateFood(); food.Draw(); Params settings = new Params(); Sounds sound = new Sounds(settings.GetResourceFolder()); sound.PlayBackground(); Score count = new Score(0); count.ScoreInGame(); Sounds soundEat = new Sounds(settings.GetResourceFolder()); while (true) { if (walls.IsHit(snake) || snake.IsHitTail()) { break; } if (snake.Eat(food)) { food = foodCreator.CreateFood(); food.Draw(); count.ScoreUp(); count.ScoreInGame(); soundEat.PlayEat(); } else { snake.Move(); } Thread.Sleep(100); if (Console.KeyAvailable) { ConsoleKeyInfo key = Console.ReadKey(); snake.Button(key.Key); } } new GameOverSnake(); sound.PlayEnd(); Thread.Sleep(5000); new EndScore(count.GetScore(), settings.GetResourceFolder()); }
public static void Main(string[] args) { Console.SetBufferSize(120, 50); // Set width and height window Walls walls = new Walls(80, 25); walls.Draw(); // draw points Point p = new Point(4, 5, '*'); Snake snake = new Snake(p, 4, Direction.RIGHT); snake.Draw(); // create food FoodCreator foodCreator = new FoodCreator(80, 25, '$'); Point food = foodCreator.CreateFood(); food.Draw(ConsoleColor.Red); // Пути и настройки Params settings = new Params(); // Audio player Sounds sound = new Sounds(settings.GetResourceFolder()); sound.Play(); Sounds sound1 = new Sounds(settings.GetResourceFolder()); // Score Score score = new Score(settings.GetResourceFolder()); // Timer Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); while (true) { if (walls.IsHit(snake) || snake.IsHitTail()) { break; } if (snake.Eat(food)) { food = foodCreator.CreateFood(); food.Draw(ConsoleColor.Red); sound1.PlayEat(); score.UpCurrentPoints(); score.ShowCurrentPoints(); } else { snake.Move(); } Thread.Sleep(100); if (Console.KeyAvailable) { snake.HandeKey(Console.ReadKey(true).Key, score); // Передается значение нажатой клавиши, но не отображается в консоли } // Timer show info TimeSpan timeSpan = TimeSpan.FromSeconds(Convert.ToInt32(stopwatch.Elapsed.TotalSeconds)); Console.SetCursorPosition(93, 23); Console.Write(timeSpan.ToString("mm':'ss")); Console.Write('\r'); } score.WriteBestResult(); score.WriteGameOver(); // Console.ReadKey(); }
static void Main(string[] args) { Console.SetWindowSize(100, 25); Console.ForegroundColor = ConsoleColor.Yellow; Console.BackgroundColor = ConsoleColor.DarkMagenta; Console.Clear(); Walls walls = new Walls(80, 25); walls.Draw(); //Otrisovka tochek 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(); Params settings = new Params(); Sounds sound = new Sounds(settings.GetResourceFolder()); sound.Play(); Sounds sound1 = new Sounds(settings.GetResourceFolder()); Sounds sound2 = new Sounds(settings.GetResourceFolder()); Score score = new Score(0, 1); score.ScoreWrite(); while (true) { if (walls.IsHit(snake) || snake.IsHitTail()) { break; } if (snake.Eat(food)) { score.ScoreUp(); score.ScoreWrite(); food = foodCreator.CreateFood(); food.Draw(); sound1.PlayEat(); } else { snake.Move(); } new Speed(score.GetScore()); if (Console.KeyAvailable) { snake.HandeKey(Console.ReadKey(true).Key); } } Console.Clear(); new WriteGameOver(); sound2.PlayGameOver(); Thread.Sleep(2000); new Results(score.GetScore(), settings.GetResourceFolder()); Console.Clear(); Best best = new Best(settings.GetResourceFolder()); Thread.Sleep(10000); }
public Game() { Console.SetWindowSize(90, 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(); Point spsfood = foodCreator.CreateSpsFood(); Point badfood = foodCreator.CreateBadFood(); food.Draw(); Params settings = new Params(); Sounds sound = new Sounds(settings.GetResourcesFolder()); sound.Play(); Counter count = new Counter(0); count.ScoreWrite(); Sounds soundEat = new Sounds(settings.GetResourcesFolder()); while (true) { if (walls.IsHit(snake) || snake.IsHitTail()) { break; } if (snake.Eat(food)) { food = foodCreator.CreateFood(); food.Draw(); count.ScoreUp(); //функция повышает вчёт очков на 1 count.ScoreWrite(); // Выводит на экран счёт soundEat.PlayEat(); // Воспроизводит звук поедания еды if (count.GetScore() % 10 == 0) //Если остаток счёта развен 0 ( то есть каждые 10 очков будет появляться спец. еда) + //получает счёт в данный момент времени и заносит в переменную { spsfood = foodCreator.CreateSpsFood(); //создаём спец еду spsfood.Draw(); //отрисовываем спец еду badfood = foodCreator.CreateBadFood(); badfood.Draw(); } } if (snake.Eat(spsfood)) //Если спец. еду съедают то ... { count.ScoreUpx3(); //увеличиваем счёт на 3 единицы count.ScoreWrite(); //выводим на экран увеличеный счёт soundEat.PlaySpsEat(); //воспроизводим звук съедания спец. еды } if (snake.BadEat(badfood)) { count.ScoreDown(); count.ScoreWrite(); soundEat.PlayBadEat(); } else { snake.Move(); } new Speed(count.GetScore()); //изменение скорости при наборе определённого количества очков if (Console.KeyAvailable) { ConsoleKeyInfo key = Console.ReadKey(); snake.MandlKey(key.Key); } } new WriteGameOver(); sound.Stop(); Thread.Sleep(1500); // Задержка на появление Игра окончена new Leader_Board(count.GetScore(), settings.GetResourcesFolder()); // Запись имени игрока + счёта ShowBestScores best = new ShowBestScores(); best.ReadFile(); //Показ лучших игроков }
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(); }