I'm trying to make a c++ snake game in linux using ansi escape codes but i can't figure out a way to get async keyboard input. Im a beginner and i'm currently reading a c++ book, so i didn't cover multithreading yet. Is there any chance to achieve this result in a "simple" way.(and standard if it's possible, i saw the kbhit solution) How to use kbhit and getch (C programming) . Can i solve the problem reading from the /dev/input event files?
Thank you guys.
C++ does not offer a standard way to asynchronously read the keyboard status.
boost asio, as in read from keyboard using boost async_read and posix::stream_descriptor is one way. Some people consider boost like a "standard" or "normal" C++ extension.
Another way is to use a game library like SDL or SFML. You include their headers and you link with their libs.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.