Skip to main content
gamedev.net
🔒 Locked

console input/output

Started by Erzengeldeslichtes Jul 13, 2004 at 10:44 PM 0 replies 300+ views
Original Post
Erzengeldeslichtes
Erzengeldeslichtes
Okay, I've worked with consoles for a while for test applications and such. Right now I need to test some fairly complex code and to test it I'm going to need some abilities in the console that I can't seem to find in help... I'm using normal C++ (no .net yet) in Microsoft Visual C++ 2005 Express Edition Beta. How do I: Set output position? Check keyboard input in real time (without stopping and waiting)? --conio.h, _kbhit(), _getch() in c, how about C++? Change console window size? Not Necessary, but would be nice to know how to: Stop the thread for 1/30th of a second but not miss realtime keyboard input? (in windows I try to use a timer message and then waitformessage when not in fullscreen mode, then I get messages for input like the mouse over and keys, which DirectInput can then poll for.) Change text/background colors. Thanks for any input. (I did a search on gamedev, but the functions I came up with were c functions, and most of them are non-existant (not deprecated, just not there) in the compiler)
----Erzengel des Lichtes光の大天使Archangel of LightEverything has a use. You must know that use, and when to properly use the effects.♀≈♂?
ApochPiQ
ApochPiQ
The Windows Console API is a great place to start. The particular functions you'll probably want are SetConsoleCursorPosition() and PeekConsoleInput(). Colors and other attributes can be set with functions like SetConsoleTextAttribute(). Changing the window size can be done (I think - I've never tried it) using the SetWindowPos() API function. You can pause a thread with Sleep() or SleepEx() - see MSDN for details - but I'm not sure if I understand correctly what it is you're wanting to do, so give them a try and see if that's what you're after.

[edit] Afterthought - you probably want to look at SetConsoleScreenBufferSize() for setting the console window size.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.