1
Programming / Re: BearLibTerminal: a pseudo-terminal window library for roguelike
« on: June 30, 2017, 05:33:09 AM »
I really enjoy using your terminal so far, however I recently stumbled upon a possible bug. I am using the python version 0.15.3 of bearlibterminal. In my game, you move around using the numpad keys (terminal.TK_KP_1, terminal.TK_KP_2, ... terminal.TK_KP_9) to allow 8-directional movement. Today I tried to implement a sprinting mechanic, where you can hold shift to sprint and move faster. This requires calling the terminal.check(terminal.TK_SHIFT) function to check if the shift key is being held down along with the movement key. However, the function returns False regardless of whether or not the shift key is held down. This is odd, because the function works correctly along with almost all other keys (including the conventional 4-direction arrow keys). Here is a short python code to test yourself.
from bearlibterminal import terminal
if __name__ == "__main__":
terminal.open()
terminal.set("window: size=100x50")
while True:
terminal.refresh()
key = terminal.read()
if terminal.check(terminal.TK_SHIFT):
print 'shift held'
else:
print 'shift not held'
if key == terminal.TK_ESCAPE:
break
terminal.close()
On my computer, the program prints 'shift not held' when I hold down shift and then press a numpad key, but prints 'shift held' when I hold down shift and press almost any other key (I haven't tested every key).
EDIT:
Upon digging a bit further, I realize that the function works when I set number lock off, but doesn't work when number lock is on.
from bearlibterminal import terminal
if __name__ == "__main__":
terminal.open()
terminal.set("window: size=100x50")
while True:
terminal.refresh()
key = terminal.read()
if terminal.check(terminal.TK_SHIFT):
print 'shift held'
else:
print 'shift not held'
if key == terminal.TK_ESCAPE:
break
terminal.close()
On my computer, the program prints 'shift not held' when I hold down shift and then press a numpad key, but prints 'shift held' when I hold down shift and press almost any other key (I haven't tested every key).
EDIT:
Upon digging a bit further, I realize that the function works when I set number lock off, but doesn't work when number lock is on.