我如何能...? [英] How do I...?

查看:59
本文介绍了我如何能...?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一个命令,(或函数,或其他什么)来查看键盘

以确定是否有任何键被按下,如果有
$ b $则不会暂停b无。 CIN>>命令暂停程序等待按键。

我想要一个循环,它将继续循环,无休止地更新屏幕,直到我按b
按一个(特定)键停止它。我正在尝试编写一个文本示例

的生命游戏。我希望能够告诉它去,并且让它运行几代直到我告诉它停止,然后返回菜单模式

用户可以打开或关闭单个单元格。


我的C ++教练无法告诉我这样做的方法。

可以吗? (已经建议将机器语言代码添加到我的程序中,但是

不是一个选项。我们不会在

课程之后再讨论如何做到这一点。更何况我不懂机器语言编程。)


全部谢谢!

解决方案

< blockquote>这是C ++的主题,但你需要研究键盘中断。你的主要问题是你的应用程序需要先关注才能确保键盘操作是专门用于它的 - 你如何做到这一点肯定是
/>
不是C ++特定的。


HTH


Aiden


" SumGie" <苏**** @ comcast.net>在消息中写道

新闻:Vo ******************** @ comcast.com ...

我需要一个命令,(或功能,或其他),将查看键盘
,以确定是否有任何键被按下,如果没有暂停,没有暂停。 CIN>>命令暂停程序等待按键。
我想要一个循环,它将继续循环,无休止地更新屏幕,直到
我按下(特定)键来停止它。我正在尝试编写一个文本
生命游戏的例子。我希望能够告诉它去,并让它运行几代,直到我告诉它停止,然后返回菜单模式,用户可以打开或关闭单个单元格。 br />
我的C ++讲师无法告诉我这样做的方法。你可以吗? (已经建议在我的程序中添加机器语言代码,
但不是一个选项。我们不会介绍如何做到这一点,直到很久以后的课程,更不用说我不做不懂机器语言编程。)

全部谢谢!




发表于Vianet.com Premium Usenet新闻组服务

---------------------------------------- ------------------

**速度**保留**完成**匿名**

- -------------------------------------------------- ------
http://www.usenet.com


SumGie schrieb:

我想要一个循环来循环,无休止地更新屏幕,直到
我按一个(特定)键来阻止它。




绝对不是C ++特定的,但去看看SDL库:

<一个rel =nofollow href =http://www.libsdl.org/target =_ blank> http://www.libsdl.org/


Arne

-

[--- PGP密钥FD05BED7 --- http://www.root42.de/ ---]


" SumGie"写道:

我需要一个命令,(或函数,或其他什么)来查看键盘
以确定是否有任何键被按下,如果有,则不会暂停没有。 CIN>>命令暂停程序等待按键。
我想要一个循环,它将继续循环,无休止地更新屏幕,直到
我按下(特定)键来停止它。我正在尝试编写一个文本
生命游戏的例子。我希望能够告诉它去,并让它运行几代,直到我告诉它停止,然后返回菜单模式,用户可以打开或关闭单个单元格。 br />
我的C ++讲师无法告诉我这样做的方法。你可以吗? (已经建议在我的程序中添加机器语言代码,
但不是一个选项。我们不会介绍如何做到这一点,直到很久以后的课程,更不用说我不做不懂机器语言
编程。)




这是在C FAQ中。

http://www.eskimo.com/~scs/C-faq/q19 .1.html


它提供指导,而不是答案。最简单的回顾一下

谷歌小组的答案,这是一个非常常见的问题。我看看

SDL库解决方案提出了upthread,它可能没问题,并且做你想要的b / b
。但我希望这种方法有一个陡峭的学习曲线。


I need a command, (or function, or whatever) that will look at the keyboard
to determine if any keys are being pressed, without pausing if there are
none. The CIN>> command pauses the program to wait for a keypress.
I want a loop that will keep looping, updating the screen endlessly, until I
press a (particular) key to stop it. I''m trying to program a text example
of the game of life. I want to be able to tell it to go, and have it
running generations until I tell it to stop, and then return to a menu mode
where the user can turn individual cells on or off.

My C++ instructor has not been able to tell me a way to do this. Can any of
you? (adding machine language code to my program has been suggested, but is
not an option. We don''t cover how to do that until much later in the
course, not to mention that I don''t know machine language programming.)

Thanks all!

解决方案

It''s off topic in C++, but you need to research keyboard interrupts. Your
main problem is that your application needs to have ''focus'' before it can
assume keyboard actions are intended for it - how you do that is definitely
not C++ specific.

HTH

Aiden

"SumGie" <su****@comcast.net> wrote in message
news:Vo********************@comcast.com...

I need a command, (or function, or whatever) that will look at the keyboard
to determine if any keys are being pressed, without pausing if there are
none. The CIN>> command pauses the program to wait for a keypress.
I want a loop that will keep looping, updating the screen endlessly, until
I press a (particular) key to stop it. I''m trying to program a text
example of the game of life. I want to be able to tell it to go, and have
it running generations until I tell it to stop, and then return to a menu
mode where the user can turn individual cells on or off.

My C++ instructor has not been able to tell me a way to do this. Can any
of you? (adding machine language code to my program has been suggested,
but is not an option. We don''t cover how to do that until much later in
the course, not to mention that I don''t know machine language
programming.)

Thanks all!



Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com


SumGie schrieb:

I want a loop that will keep looping, updating the screen endlessly, until
I press a (particular) key to stop it.



Definitely not C++ specific, but go and have a look at the SDL library:

http://www.libsdl.org/

Arne

--
[--- PGP key FD05BED7 --- http://www.root42.de/ ---]


"SumGie" writes:

I need a command, (or function, or whatever) that will look at the keyboard
to determine if any keys are being pressed, without pausing if there are
none. The CIN>> command pauses the program to wait for a keypress.
I want a loop that will keep looping, updating the screen endlessly, until
I press a (particular) key to stop it. I''m trying to program a text
example of the game of life. I want to be able to tell it to go, and have
it running generations until I tell it to stop, and then return to a menu
mode where the user can turn individual cells on or off.

My C++ instructor has not been able to tell me a way to do this. Can any
of you? (adding machine language code to my program has been suggested,
but is not an option. We don''t cover how to do that until much later in
the course, not to mention that I don''t know machine language
programming.)



This is in the C FAQ.

http://www.eskimo.com/~scs/C-faq/q19.1.html

It provides guidance, not an answer. It would be easiest to look around on
google groups for an answer, it is a very common question. I tool a look at
the SDL library solution proposed upthread, and it may be fine and do what
you want. But I would expect a steep learning curve with that approach.


这篇关于我如何能...?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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