コード例 #1
0
        static void Main(string[] args)
        {
            INITIALIZE_GAME IG = new INITIALIZE_GAME();

            IG.startGame();
        }
コード例 #2
0
        public void startGame()
        {
start:
            INITIALIZE_GAME IG = new INITIALIZE_GAME();

            Console.Clear();
            IG.Initialize();
            IG.Game_Table();
            Console.CursorVisible = true;
            tmpTable = table;
            Console.SetCursorPosition(3, 1);//game console starting position
            while (IG.life != 0)
            {
                IG.controller();
            }
            Console.SetCursorPosition(45, 17); Console.ForegroundColor = ConsoleColor.Red; Console.Write("GAME OVER!"); Console.ResetColor();
            Console.SetCursorPosition(45, 12); Console.Write("                               ");
            Console.CursorVisible = false;
            Console.SetCursorPosition(45, 19); Console.ForegroundColor = ConsoleColor.White; Console.Write("Play again?"); Console.ResetColor();
            Console.SetCursorPosition(46, 21); Console.ForegroundColor = ConsoleColor.Green; Console.BackgroundColor = ConsoleColor.White; Console.Write("YES"); Console.ResetColor();
            Console.SetCursorPosition(52, 21); Console.ForegroundColor = ConsoleColor.DarkCyan; Console.Write("NO"); Console.ResetColor();
            Console.SetCursorPosition(46, 21);
            for (; ;)
            {
                string validInput = Console.ReadKey(true).Key.ToString();
                switch (validInput)
                {
                case "RightArrow":
                {
                    if (Console.CursorLeft == 46)
                    {
                        Console.SetCursorPosition(46, 21); Console.ForegroundColor = ConsoleColor.DarkCyan; Console.Write("YES"); Console.ResetColor();
                        Console.SetCursorPosition(52, 21); Console.ForegroundColor = ConsoleColor.Green; Console.BackgroundColor = ConsoleColor.White; Console.Write("NO"); Console.ResetColor();
                        Console.SetCursorPosition(52, 21);
                    }
                    break;
                }

                case "LeftArrow":
                {
                    if (Console.CursorLeft == 52)
                    {
                        Console.SetCursorPosition(52, 21); Console.ForegroundColor = ConsoleColor.DarkCyan; Console.Write("NO"); Console.ResetColor();
                        Console.SetCursorPosition(46, 21); Console.ForegroundColor = ConsoleColor.Green; Console.BackgroundColor = ConsoleColor.White; Console.Write("YES"); Console.ResetColor();
                        Console.SetCursorPosition(46, 21);
                    }
                    break;
                }

                case "Enter":
                {
                    if (Console.CursorLeft == 52)
                    {
                        return;
                    }
                    else if (Console.CursorLeft == 46)
                    {
                        goto start;
                    }
                    break;
                }

                case "Spacebar":
                {
                    if (Console.CursorLeft == 52)
                    {
                        return;
                    }
                    else if (Console.CursorLeft == 46)
                    {
                        goto start;
                    }
                    break;
                }
                }
            }
        }