Show Posts

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.


Messages - NoahTheDuke

Pages: [1]
1
A-ha! Finally, an answer. Thanks for pointing that out; shoulda read the spec closer!

2
Hey all, it's been a little while.

I'm trying to build a small roguelike using the Python wrapper, and I can't seem to get key releases to register. Any ideas how I've messed this up?

Code: [Select]
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
Code: [Select]
.../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.

3
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

4
Is there a bug in the Python binding, in color_from_argb?

I've tried to recreate the Basic Output sample, and the color-shifting has thrown me:

Code: [Select]
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])

results in a value of `4294901760.0` being sent to `_library.terminal_color()`, which results in a `ctypes.ArgumentError: argument 1: <class 'TypeError'>: wrong type. I don't know much about bitwise operations, but does

Code: [Select]
def color_from_argb(a, r, g, b):
    result = a
    result = result * 256 + r
    result = result * 256 + g
    result = result * 256 + b
    return result

return the same result as

Code: [Select]
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;
}
?

Have I made a gross mistake in my for-loop?

Thanks either way! This library looks great, once I figure this out.

EDIT:

Fixed the problem! I changed the "return result" to be "return int(result)" so the program now runs, but it's displaying the colors differently than the provided compiled exe:


Left is provided exe, right is my Python test. Is one of them wrong? Is the sample code more recent than the sample exe? Either way, thanks!

Pages: [1]