我使用 Libtcod 在 python 中制作了一个 roguelike。当我运行代码时,会弹出窗口,在屏幕上绘制符号,但随后窗口冻结。然后它说它没有响应。我不明白发生了什么。这是代码:
import libtcodpy as libtcod;
SCREEN_WIDTH = 80;
SCREEN_HEIGHT = 50;
LIMIT_FPS = 20;
libtcod.console_set_custom_font('arial10x10.png', libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_TCOD);
libtcod.console_init_root(SCREEN_WIDTH, SCREEN_HEIGHT, 'Lets Crawl', False);
libtcod.sys_set_fps(LIMIT_FPS);
playerx = SCREEN_WIDTH/2;
playery = SCREEN_HEIGHT/2;
def handle_keys():
global playerx, playery
if libtcod.console_is_key_pressed(libtcod.KEY_UP):
playery -= 1
elif libtcod.console_is_key_pressed(libtcod.KEY_DOWN):
playery += 1
elif libtcod.console_is_key_pressed(libtcod.KEY_LEFT):
playerx -= 1
elif libtcod.console_is_key_pressed(libtcod.KEY_RIGHT):
playerx += 1
while not libtcod.console_is_window_closed():
#libtcod.console_set_default_foreground(0, libtcod.white);
libtcod.console_put_char(0, 1, 1, 'b');
libtcod.console_flush();