I'm working on a text adventure game:
#include <string>
#include <cstdio>
using namespace std;
int main (){
cout << "Welcome to text adventure! Do you want to play? (y/n)\n";
char ansr;
cin >> ansr;
while (ansr == 'y' || 'Y'){
cout << string (50, '\b');
cout << "Okay, let's go!";
return 0;
}
}
This works alright, but for readability I want the new text "okay, let's go!" to appear at the top of the screen. This is part of an educational assignment, but i really like my idea for my text adventure game. system(CLS);
Does the job but i've been reading that there are some major portability issues with this since it can only work with windows.
I've tried resplacing \n
with \b
and it doesn't do anything because \b
is only meant to erase what the console is typing. I'm wondering if there's a way the earlier things that were printed on the console. If not, are there any other alternatives to system(CLS)
other than what I have on there to allow the new text to be bumped up to the top of the screen?