コード例 #1
0
 static void Main()
 {
     Console.Title = "POPEYE";
     sp.PlayLooping();
     PrintInscriptions.SetIntroPositionsAndColors();
     sp.Stop();
     player.PlayLooping();
     windowHeight    = Console.BufferHeight = Console.WindowHeight = 20;
     playfieldHeigth = windowHeight - 5;
     windowWidth     = Console.BufferWidth = Console.WindowWidth = 40;
     Console.Clear();
     Console.OutputEncoding = Encoding.Unicode;
     Console.CursorVisible  = false;
     Console.SetCursorPosition(0, playfieldHeigth);
     Console.WriteLine(new String('═', windowWidth));
     PrintLiveScore();
     PrintScore();
     PrintLevels();
     PrintCollected();
     PrintOnStringPosition(15, playfieldHeigth / 2, "Level " + levels, ConsoleColor.Gray);
     Thread.Sleep(1500); //time for seeing the text "Level 1" on the console
     popeyeX         = playfieldHeigth / 2;
     playfieldMatrix = new char[playfieldHeigth, windowWidth];
     playfieldMatrix[popeyeX, popeyeY] = popeyeSymbol;
     GenerateRightColumnOfSymbols(playfieldHeigth, windowWidth, playfieldMatrix);
 }
コード例 #2
0
        static void GameOver()
        {
            Console.ForegroundColor = ConsoleColor.Green;
            Console.SetCursorPosition(5, 5);
            Console.Clear();
            windowHeight            = Console.BufferHeight = Console.WindowHeight = 50;
            windowWidth             = Console.BufferWidth = Console.WindowWidth = 170;
            Console.ForegroundColor = ConsoleColor.Red;
            try
            {
                gameOver.Load();
                gameOver.Play();
                StreamReader bombPicture = new StreamReader(@"..\..\bombPicture.txt");
                using (bombPicture)
                {
                    string line = bombPicture.ReadLine();
                    while (line != null)
                    {
                        Console.WriteLine(line);
                        line = bombPicture.ReadLine();
                    }
                }
            }

            catch (FileNotFoundException)
            {
                Console.WriteLine("Missing file of the bomb picture!");
            }
            Console.ForegroundColor = ConsoleColor.White;
            Console.SetCursorPosition(75, 1);
            Console.WriteLine("YOUR FINAL SCORE: {0}", score);
            Thread.Sleep(800);
            PrintInscriptions.PrintNiceAlphabet("you are dead", 30, 15, ConsoleColor.Yellow);
            PrintInscriptions.PrintNiceAlphabet("my muscled friend", 40, 25, ConsoleColor.Blue);
            Thread.Sleep(4000);
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.Clear();
            PrintInscriptions.PrintNiceAlphabet("play again", 30, 5, ConsoleColor.Yellow);
            PrintInscriptions.PrintNiceAlphabet("press y for", 15, 20, ConsoleColor.Red);
            PrintInscriptions.PrintNiceAlphabet("yes", 125, 20, ConsoleColor.Red);
            PrintInscriptions.PrintNiceAlphabet("or", 60, 30, ConsoleColor.Blue);
            PrintInscriptions.PrintNiceAlphabet("press n for", 15, 40, ConsoleColor.Green);
            PrintInscriptions.PrintNiceAlphabet("no", 125, 40, ConsoleColor.Green);
            while (true)
            {
                try
                {
                    switch (Console.ReadKey(true).Key)
                    {
                    case ConsoleKey.Y:
                        score     = 0;
                        liveScore = 3;
                        levels    = 1;
                        popeyeY   = 0;
                        Console.Clear();
                        Console.SetCursorPosition(0, 0);
                        Main();
                        break;

                    case ConsoleKey.N:
                        Console.Clear();
                        Environment.Exit(-1);
                        break;

                    default: throw new ArgumentException();
                    }
                }
                catch (ArgumentException)
                {
                    Console.Clear();
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("Invalid key, press 'Y' to play again or 'N' to exit !");
                    Console.ResetColor();
                }
            }
        }