View Full Version : NCURSES [curses.h]
Okay, I'm facing this simple dilema. What I need is for a loop in C++ to keep going until a keystroke is hit. Now, the problem with using regular cin for that is that it prompts the user for a keystroke. That's not going to work here, as I'm creating a colored version of Tetris in an xterm, and waiting for a keystroke would mean that the user would win no matter what. :p
Anyone who knows how to use ncurses, your help is MUCH appreciated.
Thanks in advance. Any solution is welcome. [BTW, this is a *nix only thing]
Canuckkev
June 1st, 2002, 01:02
Hmm...I'm a very C++ newbie...and I know you know lots...so I doubt !kbhit() is what your looking for, right? Might be only a VS thing...
Anyways...I think you need stdlib.h included, and usage would be like:
while(!kbhit()){
blah blah blah....does all this untill you press a key
}
Doubt it is what you are looking for...oh well. Works good for my bowling game :D
Heh, I'll try it out. :)
I'm in an AP class, so we use these bull---- classes that the CollegeBoard creates, which means we never learn anything else. :p
[add]
It doesn't work, as it's not in stdlib.h. :confused2
[add2]
Checked through 2 versions of stdlib, you sure it's in there? :confused:
Also, does it return a bool or a char?
Canuckkev
June 2nd, 2002, 20:06
Doh! It's it conio.h . Don't know what it returns...but I assume a bool. Oh, and you need to flush it. A getch() placed somewhere after the loop should do it, so in a larger loop it will go back into the while(!kbhit()) one.
getch() is in conio.h as well.
Well, conio.h / nwconio.h is a Windows-header file, so that doesn't help me at all. I'm still trying to get info on how to use curses.h
I think this is not a good place to put questions on C++ as this is a freewebspace forum try to put this on C-Programming (http://www.cprogramming.com) or ProgrammersHeaven (http://www.programmersheaven.com) There would surely a lot of replies......
Powered by vBulletin® Version 4.1.7 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.