views:

375

answers:

2

I've started fiddling with C to improve my programming skills, and decided to try and implement a Tetris game. Nothing too fancy, it'll run on the console.

I never implemented a game that keeps running despite user input, and didn't figure out I'd have to deal with this problem until I started thinking about the game algorithm.

Googling for a solution I came up with a _kbhit() function, but I'm programming on a Linux box and that function is only available on Windows. How can I do it?

+3  A: 

For a console app, you could look into using GNU ncurses, it is a sort of toolkit for writing console applications, and supports such input. It should also help you with your game's output, by providing ways to print characters at coordinates, and so on.

unwind
A: 

To be able to intercept special characters, switch the terminal into non-canonical mode

dmityugov