这是我的代码,我是一个初学者,我已经看了至少5-10篇关于这方面的文章,他们对我没有真正的帮助,因为我不能理解代码。
在我的代码中,我尝试了一个非常基本的游戏开始屏幕,我想要做的是如何检测在开始屏幕上按下的E或S,
print (" _____________________________________________ ")
print ("| |")
print ("| |")
print ("| The Chronicles |")
print ("| Of Game |")
print ("| |")
print ("| |")
print ("| |")
print ("| |")
print ("|_____________________________________________|")
print ("| |")
print ("| START EXIT |")
print ("| (S) (E) |")
print (" \___________________________________________/ ")发布于 2015-10-03 08:17:02
我使用getch,如果你想使用,请下载py-getch:
https://github.com/joeyespo/py-getch
要安装的命令: python setup.py安装
示例代码:
from getch import getch, pause
# game loop
while(True):
key = getch()
if(key == 'S'):
print('key S pressed...')
elif(key == 'E'):
print('key E pressed...')

https://stackoverflow.com/questions/32917514
复制相似问题