Sign in to follow this  
Ryan_Burnside

[C++] Cross platform text console?

Recommended Posts

Hello,

I've currently been toying quite a bit with the idea of a console window text based game.

My target platforms will be the Windows PC and also Linux PC.

Currently I have a 2d array that works as a sort of screen buffer.

[code]

string the_buffer[x][y]; // string buffer lets us use either unicode or ascii single characters between OSs

for(char y = 0; y < 20; y++)
{
for(char x = 0; x < 64; x++)
{
// add string value to current line
cout << the_buffer[x][y];
}
// move to next line
cout << endl;
}
[/code]

Now I have everything drawing to the screen but I would like a platform independent way to keep blitting the buffer's contents to the screen. Also there must be some form of verticle synchronization so the screen does not have flashing and missing lines as the buffer refreshes.

Also, I ask the veterans of character based games, what do I need to look out for when making a cross platform solution with the console window?

Share this post


Link to post
Share on other sites
You might want to look into an existing library like [url=http://pdcurses.sourceforge.net/]pdcurses[/url].

Share this post


Link to post
Share on other sites
I would actually recommend Java for a project like this as it's made to be portable across platforms and the usual reasons people don't use Java for games (speed, memory usage, what have you) are a non-issue in a text-based game. You can do it in C/C++, of course, but you'll have to compile it for each system. That's not so bad, of course, but using something like Java trivializes it for you. =)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this