非阻塞getch() [英] Non blocking getch()

查看:235
本文介绍了非阻塞getch()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在标准控制台中制作俄罗斯方块游戏.我需要无阻塞的getch(),因此无需按任何键即可使块掉落.如果没有按任何键,则返回-1即可,否则返回键代码.

I'm trying to make Tetris game in standard console. I need non-blocking getch(), so the blocks can fall without pressing any key. It would be nice to have function that returns -1 if no key pressed, otherwise the key code.

推荐答案

它是特定于操作系统的,但是您的库可能具有一个名为kbhit()或类似功能的函数

It's operating system specific but your library probably has a function called kbhit() or similar that will do this

这篇关于非阻塞getch()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆