Note that there are some explanatory texts on larger screens.

plurals
  1. POPython Roguelike: Inventory Disappears
    text
    copied!<p>Today I progressed further into <a href="http://roguebasin.roguelikedevelopment.org/index.php?title=Complete_Roguelike_Tutorial,_using_python%2Blibtcod" rel="nofollow">this Python roguelike tutorial</a>, and got to the inventory. As of now, I can pick up items and use them. The only problem is, when accessing the inventory, it's only visible for a split second, even though I used the <code>console_wait_for_keypress(True)</code> function. I'm not sure as to why it disappears. Here's the code that displays a menu(in this case, the inventory):</p> <pre><code>def menu(header,options,width): if len(options)&gt;26: raise ValueError('Cannot have a menu with more than 26 options.') header_height=libtcod.console_get_height_rect(con,0,0,width,SCREEN_HEIGHT,header) height=len(options)+header_height window=libtcod.console_new(width,height) libtcod.console_set_default_foreground(window,libtcod.white) libtcod.console_print_rect_ex(window,0,0,width,height,libtcod.BKGND_NONE,libtcod.LEFT,header) y=header_height letter_index=ord('a') for option_text in options: text='('+chr(letter_index)+')'+option_text libtcod.console_print_ex(window,0,y,libtcod.BKGND_NONE,libtcod.LEFT,text) y+=1 letter_index+=1 x=SCREEN_WIDTH/2-width/2 y=SCREEN_HEIGHT/2-height/2 libtcod.console_blit(window,0,0,width,height,0,x,y,1.0,0.7) libtcod.console_flush() key=libtcod.console_wait_for_keypress(True) index=key.c-ord('a') if index&gt;=0 and index&lt;len(options): return index return None </code></pre> <p>I'd appreciate anyone's help or input to this problem.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload