1
Programming / Re: BearLibTerminal: a pseudo-terminal window library for roguelike
« on: November 16, 2016, 01:59:36 AM »
A-ha! Finally, an answer. Thanks for pointing that out; shoulda read the spec closer!
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
import PyBearLibTerminal as terminal
terminal.open()
terminal.printf(2, 1, 'β')
terminal.put(2, 2, 'β')
terminal.refresh()
while True:
if terminal.has_input():
key = terminal.read()
print(key)
if key == terminal.TK_Q | terminal.TK_KEY_RELEASED:
print('released')
break
elif key == terminal.TK_Q:
break
terminal.close()
produces.../Programming/Python/roguelike python3 test.py
4
22
7
44
20
.../Programming/Python/roguelike
Has anyone experienced this before? Have I done something wrong or set something up wrong? I haven't tried this on my Windows machine, but I'll be sad if I can only access key releases on Windows.
It would be pretty awesome if the RogueBasin's Python tutorial was modified by someone to use this for rendering and the libtcod would be used for the pathfinding and other utilities.I'm working on my own roguelike, and once I'm at a place I feel comfortable sharing, I'm going to iterate over it in a tutorial fashion, and then post it up on RogueBasin. Which is to say, give me a month! :-D
for i in range(long_word_len):
factor = i/long_word_len
red = (1 - factor) * 255
green = factor * 255
terminal.color(terminal.color_from_argb(255, red, green, 0))
terminal.put(2+n+i, 1, long_word[i])
def color_from_argb(a, r, g, b):
result = a
result = result * 256 + r
result = result * 256 + g
result = result * 256 + b
return result
TERMINAL_INLINE color_t color_from_argb(uint8_t a, uint8_t r, uint8_t g, uint8_t b)
{
return ((color_t)a << 24) | (r << 16) | (g << 8) | b;
}
?