Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Linux Shell Game Input

Name: Squeezy !31sNfzlFrg 2010-10-08 15:40

I'm writing a simple Linux Game in C++ for school, I've been using getch for my input controls for Up Down Left Right. The problem is that getch blocks the program from continuing. Online I gathered that kbhit may be a better option, except there are over 10 different kbhit.h's and they dont fucking work. if(getch) in a while(1) loop would be totally fucking fine if i could have like a 1ms timeout for getch so if there is no key pressed the screen keeps going. What do?

Name: Anonymous 2010-10-09 23:24

>>20
Yeah, you shouldn't link against libraries, ever.  Like, all you need is the syscall opcode which is like one line of assembler.  You especially shouldn't link against something like ncurses, which is well-tested, works practically everywhere, is installed practically everywhere, and allows the programmer to use ECMA-48 control codes on a wide variety of terminals portably without having to read the 108-page ECMA-48 specification.

Only trolls will tell you not to use libraries.  The ncurses library can put your terminal in raw mode so you don't have to look up a bunch of escape sequences and parse / emit them by hand.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List