public Program()
 {
     input                 = new BlockingCollection <ConsoleKey>();
     inputThread           = new Thread(ReadKeys);
     gameObjects           = new List <GameObject>();
     buffer2D              = new DoubleBuffer2D <char>(XMAX, YMAX);
     Console.CursorVisible = false;
 }
        // Program constructor
        private Program()
        {
            // Game objects which will exist in our game
            GameObject background, player;

            // Components
            KeyReaderComponent krc;

            // Create a double buffer for rendering
            buffer2D = new DoubleBuffer2D <char>(worldDimX, worldDimY);

            // Instantiate the list of game objects
            gameObjects = new List <IGameObject>();

            // Create the background game object and add it a Background
            // component
            background = new GameObject("Background");
            background.AddComponent(
                new BackgroundComponent(buffer2D, worldDimX, worldDimY));

            // Create the player game object and add it a key reader
            // component (to capture input) and a move component, for moving
            // the player according to the input
            player = new GameObject("PlayerX");

            // Create the key reader (to capture input)
            krc = new KeyReaderComponent();
            // Set action to perform when escape is pressed
            krc.EscapePressed += () => running = false;
            // Add the key reader component to the player game object
            player.AddComponent(krc);

            // Add a move component, for moving the player
            player.AddComponent(new MoveComponent(
                                    worldDimX / 2, worldDimY / 2, worldDimX, worldDimY, buffer2D));

            // Add both game objects to the game object list
            gameObjects.Add(background);
            gameObjects.Add(player);

            // Important notes:
            // 1 - The key reader component approach used here is not usable
            //     when different game objects require input. Input processing
            //     should be done before game object updates().
            // 2 - The rendering depends on the order in which game objects are
            //     added to the game object list. This might work for simple
            //     games, but soon becomes unmanageable when the games starts
            //     becoming a bit more complex
            // ->  See https://github.com/fakenmc/CoreGameEngine/ for a more
            //     versatile (and more complex) solutions
        }