Example #1
0
        public void Draw(MineSweeperGame game)
        {
            var stateText = game.GetGameStateText() + "\r\n";

            BoardOffsetY = GetLineCount(stateText);

            Clear();

            // status text
            Console.BackgroundColor = ConsoleColor.Black;
            Console.ForegroundColor =
                game.HasFailed ? ConsoleColor.Red
                : game.HasWon ? ConsoleColor.Blue
                : ConsoleColor.Yellow;
            Console.WriteLine(stateText);

            // board text
            Console.CursorSize      = 100;
            Console.BackgroundColor = ConsoleColor.White;
            Console.ForegroundColor =
                game.HasFailed ? ConsoleColor.Red
                : game.HasWon ? ConsoleColor.Cyan
                : ConsoleColor.DarkGray;
            Console.WriteLine(GetBoardString(game.Board));

            Console.BackgroundColor = ConsoleColor.Black;
        }
Example #2
0
        static void Main(string[] args)
        {
            var graphics = new ConsoleGraphics();
            var board    = new Board(64, 32, 0.1);
            var game     = new MineSweeperGame(graphics, board);

            game.Play();
        }