How can I resize console window in a minigame task (C# Foundation module 5.5)?

Hello. Task demands from me to make a method, which will check is console window resized or not. I should test this, running the app, then resizing the window by command prompt and trying to move my “character”. But how can I resize the window while console is busy by “game”? Should I make a method, which allows a player to resize window? But logically this is a nonsense

The starter code for the exercise should include a method called TerminalResized(). There are no modifications to the TerminalResized() method itself that are required. You will however need to call it. I called the TermianlResize() method within the while loop of InitializeGame(). I did this because the I interpreted the bullet point “Determine if the terminal was resized before allowing the game to continue” as only calling InitializeGame() between games.

while (!shouldExit)
if (TerminalResized())
Console.WriteLine(“The windows was resized and the game has ended.”);
shouldExit = true;


Hopefully this helps.

Hello. Thanks for answer, but if I understand right, the task demands from us to check in the Resize Method, " * Determine if the terminal was resized before allowing the game to continue", so rthis method should return bool value and this value we can get checking if user resizes console window
Logically, “player” can “cheat” resizing window, so we should exit program, if notice that, but how can he resize Console window while it is busy by “game” and doesnt’t allow to tyoe any console commands?

Hi, I just re-tested the program and the game does exit if the player resizes the window at any point. This is because the if block that calls the TerminalResized() method is inside the InitializeGame()'s while loop. The while loop is run each time the player makes a move and checks the value of shouldExit. In this case TerminalResized() returns true, so shouldExit get set to a value of true which would break the InitializeGame() while loop.