我正在使用curses在python中创建一个控制台游戏但是我找不到一个从屏幕上获取字符串的函数。
的Python :
import curses
############
# Game Map #
############
gameMap = """
##########
#________#
#________#
##########
"""
gameWin = curses.initscr()
curses.cbreak()
curses.curs_set(0)
gameWin.keypad(1)
gameWin.clear()
gameWin.addstr(gameMap)
gameWin.addstr(playerY, playerX, playerIcon)
game_over = False
while game_over == False:
c = gameWin.getch()
if c == curses.KEY_RIGHT ## and gameWin. some function (playerY,playerX+1) != "#":
#### this line ^^^^
playerX += 1
gameWin.clear()
gameWin.addstr(gameMap)
gameWin.addstr(playerY, playerX, playerIcon)
curses.nocbreak(); gameWin.keypad(0); curses.echo()
curses.endwin()
正如您所见,我想在playerY
playerX
gameWin
获取字符串
我试过了getstr