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); }
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 bool Main() { Render rnd = new Render(); int selected; Random random = new Random(); Sounds snd = new Sounds(); bool win; snd.Music(random.Next(1, 5)); do { rnd.Menu(skalkamode); } while(!int.TryParse(Convert.ToString(Console.ReadKey(false).KeyChar), out selected)); switch (selected) { case 0: { return(false); } case 1: { Game game = new Game(border, body, point, space, delay, shortdelay); Console.Clear(); snd.Stop(); win = game.Start(skalkamode); if (win) { snd.Sound("win"); rnd.Win(); Thread.Sleep(2000); } else { snd.Sound("win"); rnd.Gameover(); Thread.Sleep(2000); } Console.Clear(); break; } case 2: { Console.Clear(); Console.SetCursorPosition(0, 0); Console.Write("Work in progress (press any key)"); Console.ReadKey(); break; } case 3: { Console.Clear(); Console.SetCursorPosition(0, 0); Console.Write("Move by arrows (double tab dirrectio for sprint). /nYou can pause game by draging mouse over the game area. /nIf you go to border, yourself or backwards, you gona die."); Console.ReadKey(); break; } } return(true); }
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(); }