Making a console game into a window with #include <windows.h>

I couldn't find a good way to phrase the title. Here's what I want to do:
I'm making a text-based game. I currently have it running in console (some code below), and it works just fine for what I have so far. However, I'm making it using #include <iostream>, with mainly cin's and cout's, and I'm going to throw some pointers in for navigation from game squares. My problem with it is that while it works fine in the console, the aesthetics aren't good -- most people would rather play their game in a window than in console. What I need to know is how to make a window with an interactive text box that, depending on the command typed, has a pointer to a different part of the game.

The code I have so far:

#include <iostream>
#include <string>
using namespace std;

int main()
{
	char takeDagger;
	string input;


	cout<<"You wake up and feel light-headed. You try to think of what happened," << endl;
	cout<<"but you can't remember anything." << endl;
	cout<<"The last thing you recall is walking down the street, and then..." << endl; 
	cout<<"you woke up here, in what seems to be an abandoned cabin.\n" << endl;
	cout<<"You look around and see a worn-down fireplace, full of ashes from a fire" << endl;
	cout<<"whose heat was lost to the world long ago.\n" << endl;
	cout<<"Above the fireplace you see a rusted dagger. You should probably 'take'.\n" <<endl;
	getline(cin, input);
		if(input == "take") {
			cout<<"You took the dagger\n";
		}
		else {
			cout<<"Invalid command. Please try again." << endl;
		}
		while (input != "take") {
		getline(cin, input);
		if(input == "take") {
			cout<<"You took the dagger\n";
		}
		else {
			cout<<"Invalid command. Please try again." << endl;
		}
		}
		system("pause>nul");
}



The program is currently just in one square of the game and has the option to take the dagger. If the user types "take", they take the dagger, and the program completes (will later give different text, and start them on the game), and if they type something else, it tells them it's an invalid command, and restarts the asking for a command.
closed account (ozUkoG1T)
hey good work but i suggest rather than using:
system("pause>nul");
use:
cin.get();
but anyway i liked you're game good work!
To do any non-console GUI stuff, you are really going to start getting into complicated stuff.

There are a few routes you could take:
Pure WIN32 (easiest to do in C instead of C++):
The easiest way to do this is to make a giant EDIT box with CreateWindowEx from <Windows.h>. You would get inputs with: GetWindowTextLength() and GetWindowText(). You would set outputs with: SetWindowText().

MFC (C++ wrapper for WIN32):
I don't have much experience with this, but many things are already templated for you here. You just put in what you want.

Qt (Cross-platform):
Very nice platform. Creating a text-editor is one of the simple tutorials on their website so you should be able to go from there.

OpenGL with SFML
SFML is a library which makes graphics easy. There are some really good tutorials about drawing shapes, controlling them with sprites, moving the camera, etc. If you want something text-based, then you will need to map in each keyboard input and draw them on the screen where you want it. Then you'll need to draw the response from the game.

There are some ideas to get you started. Start searching around and seeing what looks easiest to you.
Topic archived. No new replies allowed.