Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

MTT

Getting a players name

This topic is 5354 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am currrently working on an ascii rpg and have run into a little problem. Right now i need to make it so when you start a new game it asks for your name, which wasnt too hard with my text output function. What i tried doing was initializing the string szpName, having my game putting out on the screen "Enter your name: " in a certain location, then going cin >> szpName. The problem was that the place that the writing was going to was down on the next line, and was getting in the way of everything. Now what i either need is for sombody to tell me how to make the place my writing is going directly after the text, or a completely diffent way. If i wasnt clear enough on what my problem was just tell me and i''ll put up a screenshot.
No left turn unstoned

Share this post


Link to post
Share on other sites
Advertisement
TextOutput("", "Enter your name: ", 0, 22, 18, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE, 5);
cin >> szpName;

This is the code



No left turn unstoned

Share this post


Link to post
Share on other sites
Heya,

I am not familiar with the TextOut. However, this is how I would do it in C++, in a standard console program:



string szpName;

cout << "Enter Name: ";
cin >> szpName;

cout << "Hello " << szpName << "!";



The output would be:

Enter Name: Chris
Hello Chris!

This would keep your request for the name and the input on the same line.

Share this post


Link to post
Share on other sites
quote:
Original post by falkone
gotoxy()


Can you explain to me how this works and how to use it?

Share this post


Link to post
Share on other sites
quote:
Original post by Chryzmo
Heya,

I am not familiar with the TextOut. However, this is how I would do it in C++, in a standard console program:



The TextOut was a funtion i put in myself, so that i could set the location and colour of the text (and a few other things). The problem with the cin is that for some reason it is starting at the next line, i cant really explain why.

Share this post


Link to post
Share on other sites
quote:
Original post by MTT
quote:
Original post by falkone
gotoxy()


Can you explain to me how this works and how to use it?


Oh come on, where''s the fun in that?

Share this post


Link to post
Share on other sites
Here is a screenshot of my problem, i have no idea why it is doing this, it doesnt jump to the next line if i dont do the cin function. I have used cin in other things and it did not make it jump to the next line, can sombody please explain to me how to fix this, i would be very greatful. Oh, and stting the cursors position didnt fix the problem.


Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!