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 - NetworkingGuru

Pages: [1]
1
OK, I figured it out, and the reason is so weird (to me, anyway) that I'm posting it in case others run into it. What I was doing was instantiating and running two separate terminals while I converted, one through libtcod and one through blt, using the same inputs but different functions. Why this would interfere with each other, I do not know, but it does. If I comment out the 'render all' function for either one, the other works perfectly.

2
Have you tried playing around with layers and composition? It can often be easier to turn composition off to make things simpler and I know that it was the cause of a few problems for me and I only turned it back on once I had specific plans for it. One potential issue you might have is that you’re effectively overwriting characters but it’s a bit hard to tell from what you’ve posted.

Thanks. I'm using the default values (according to docs 'TK_OFF'), but I explicitly set it and checked it as well in my init code and it does appear to be off:
Code: [Select]
def create_terminal(w,h) -> object:
    term = terminal.open()
    terminal.set('window: size='+str(w)+'x'+str(h)+',title=Crimson Sands; font: fonts\\cp437_8x8.png, size=8x8, codepage=437')
    terminal.composition(terminal.TK_OFF)
    terminal.refresh()
    if terminal.state(terminal.composition) == terminal.TK_OFF: print('Comp Off')
    return term

3
I'm getting a weird issue with blt in python where my fonts are basically just blocks of color. Here's an example:



The one just showing blocks of white is blt, the other is the same code (more or less) in libtcod. I've tried setting background and foreground manually and also using puts instead of printf. Nothing changes unless I change the fireground color, and then I get a new colored block instead of white. As an example, here's the block of code used to render the top line of both images:

BLT:
Code: [Select]
terminal.printf(ox, oy, '[color=white][bg_color=black]Hit Location')
terminal.printf(ox+15, oy, 'DERM')
terminal.printf(ox+20, oy, 'TIS')
terminal.printf(ox+25, oy, 'BONE')


Libtcod:
Code: [Select]
libtcodpy.console_print_ex(con, log.x, 0, libtcodpy.BKGND_NONE, libtcodpy.LEFT, 'Hit Location')
libtcodpy.console_print_ex(con, log.x+15, 0, libtcodpy.BKGND_NONE, libtcodpy.LEFT, 'DERM')
libtcodpy.console_print_ex(con, log.x+20, 0, libtcodpy.BKGND_NONE, libtcodpy.LEFT, 'TIS')
libtcodpy.console_print_ex(con, log.x+25, 0, libtcodpy.BKGND_NONE, libtcodpy.LEFT, 'BONE')


Any help is greatly appreciated. I feel like I'm having a heck of a time figuring out how to do some fairly basic things in BLT.



4
If I understand your question properly, this is what my code on that point looks like:
Code: [Select]
key = blt.read()
if blt.check(blt.TK_CHAR):
key_char = chr(blt.state(blt.TK_CHAR))
else:
key_char = None
And then I test the key and key_char variables like this:
Code: [Select]
if key == blt.TK_KP_1 or key_char == 'b':

Yep, that's exactly what I was looking for, thanks so much!

5
I'm converting my game from libtcod to bearlibterm (python), and I've run into an issue. Is there a function in bearlibterm to return the keycode or character associated with a keystroke, similar to what I can do with chr(event.sym) in tcod? Seems super tedious to build a function to convert all of the bearlibterm constants back into keycodes, but I can't figure out another way to do it.

In case it matters, I'm using a CP437 font (though it seems like that's an output issue and shouldn't matter for detecting input).

Pages: [1]