Ejemplo n.º 1
0
        // Prompt
        //
        // A little "command-prompt" if you like. Where are the letters you
        // type will gather up.
        //
        // I will probably move `Prompt` out of the `MatrixConsole` and into
        // `Display` where it's simply returned as a string, but it's more
        // cumbersome ATM since it needs to be positioned at the bottom edge.

        public static void Prompt(string input, string word)
        {
            int center = Console.WindowWidth / 2;

            Console.CursorLeft      = 0;
            Console.CursorTop       = Console.WindowHeight - 1;
            Console.BackgroundColor = ConsoleColor.DarkGreen;
            Console.ForegroundColor = ConsoleColor.Black;

            // Last input
            Console.Write(input[input.Length]);

            // Word input
            if (!string.IsNullOrEmpty(word) && input.Length > 0)
            {
                Console.CursorLeft = center;
                Console.Write(word);
                Console.CursorLeft      = center;
                Console.ForegroundColor = ConsoleColor.Green;

                foreach (char letter in input)
                {
                    if (word.IndexOf(letter) != -1)
                    {
                        MatrixConsole.WriteOnTop(letter.ToString());
                    }
                }
            }
        }
Ejemplo n.º 2
0
        // Draws the Matrix

        private Game Render()
        {
            World world = this.World;

            switch (world.State)
            {
            // Introduction is just a static screen that requires input about
            // the level of difficulty of the game. Since the screen ATM is
            // static, we do not need to refresh on every tick.

            case Game.State.Introduction:
                Console.Clear();
                MatrixConsole.Write(this.Display.Introduction());
                Console.ResetColor();
                break;

            // Level up is a little pause you get every now and then, so your
            // brain-juice doesn't vaporize immediately. The screen is static
            // ATM and so, does not need to be refreshed on every tick.

            case Game.State.LevelUp:
                Console.Clear();
                MatrixConsole.Write(this.Display.Level(world.Level));
                Console.ResetColor();
                Thread.Sleep(this.LevelDelay * 1000);
                break;

            // Running, is the actual game-play. Here the screen is totally
            // dynamic and the app really comes alive.

            case Game.State.Running:
                Console.Clear();
                MatrixConsole.Prompt(world.CurrentInput.ToString(), world.CurrentWord);
                Console.ResetColor();
                break;

            case Game.State.Ended:
                Console.Clear();
                MatrixConsole.Write(this.Display.GameOver(world.Accuracy(), world.Score()));
                Console.ResetColor();
                break;
            }

            return(this);
        }