Suadeo

Hello all,

Currently I am learning C# mostly to play with XNA. While I understand alot of the concepts of the language, I have decided to start a project to continue my learning. My goal right now is to make something like a roguelike. While not as complex as one, I would like to beable to draw a room, display the man and enemy, and have various actions they can perform. This is where my question comes in.

Is there a way in C# to people to split a console window into different forms and control them I don't know if thats the best way to say it, so I will give an example. On a 80x25 console, I wish to split it into a 40x25 and another 40x25 'form'. One of the forms will display the actions you can perform (this will only needed to be update very rarely) and the other will have the room, the man and the enemy (this will be update everytime the player presses a valid action key [cast, walk, attack, etc]).

If this is possible, my other question is this: Is it possible to redraw each form independently One form may need to be redrawn once every 10 turns, while the other will need to be drawn every turn.

Thank you in advance!




Re: Visual C# Express Edition C# and ...roguelike?

AmazingAnt

So what you're looking to do is split each line into two "rows", correct
To do that, about the best thing you could do is create two strings, put them each together, and then write them both.

Code Block

string TopRow;

string BottomRow;



TopRow = "your nice little display here."; //You can use Environment.NewLine for linebreaks



BottomRow = "Actions go here."; //You might want to use the PadLeft and PadRight methods



Console.WriteLine(TopRow);

Console.WriteLine("-------------------------");

Console.WriteLine(BottomRow);



Unfortunately, there isn't much of any way you could redraw the top or bottom on it's own, but in the meantime, good luck with your program work. Smile





Re: Visual C# Express Edition C# and ...roguelike?

Chunsheng Tang - MSFT

Hi, Suadeo

I believe few people here are familar with XNA.Please visit XNA forums for suggestions:

http://forums.xna.com/






Re: Visual C# Express Edition C# and ...roguelike?

IsshouFuuraibou

That is false. There are ways to "redraw" section of the console without overwriting other sections.

I would suggest that you get more familiar with the console class: System.Console

Specifically two methods to look at are MoveBufferArea (and associated buffering) and the SetCursorPosition such that you can move your cursor around and write over what's shown. There will be a fair bit of managing that you'll have to do because you really can't rely on console to keep records particularly of past actions to show in the history. You'll need to make sure that you always end with a blank line (or two) for input such that you'll never end up scrolling your top off.

You can't "separate" the console window, but you can manually adjust the different areas. It may be that making a simple GUI that provides the separation and logging might be easier, but I don't know what you want to do fully. (IE: you can make a form with two rich text boxes, one for commands/notices and one for the ascii text image )