Pygame 写入其他终端? [英] Pygame Write to other terminal?

查看:66
本文介绍了Pygame 写入其他终端?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否可以将 pygame 代码写入单独的终端,以便您仍然可以执行诸如打印到终端之类的操作.当 pygame 的显示被初始化时,似乎不可能将任何输入放入终端.有什么办法可以解决这个问题?

I was wondering if it is possible to write the pygame code to a separate terminal so that you can still do things like print to the terminal. When pygame's display becomes initialized it seems to be impossible to put any input into the terminal. Any way to get around this?

我还想知道,如果可能的话,另一个终端是否可以编辑运行 pygame 的终端以更改某些内容?

I also want to know that if this is possible can one the other terminal edit the one running pygame to change certain things?

Github

推荐答案

好的,一旦您初始化 pygame 并在 Commands.py 的 startDisplay() 中启动您的 pygame 循环,您实际上将 main() 循环留在了 game.py 中.因此,您的重复输入请求不会再次发生.如果您想在 startDisplay() 的循环期间调用输入,您需要在那里明确地进行.如上所述,这将暂停您的游戏,直到您输入命令,这显然不是很好.您可以围绕它构建一些逻辑,并仅在操作中断期间请求输入或实现暂停事件(使用按键事件),随后会调用命令提示.

Ok, once you initialize pygame and start your pygame loop in startDisplay() in Commands.py, you are essentially leaving your main() loop in game.py. So your repeated request for input won't happen again. If you want to call for input during the loop in startDisplay() you'll need to do it expressly there. As I stated above, this will pause your game until you enter a command, which obviously isn't very good. You could build a little logic around it and only request input during a break in the action or implement a Pause event (using a key event) which would subsequently call the prompt for a command.

这篇关于Pygame 写入其他终端?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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