Author Topic: BearLibTerminal: a pseudo-terminal window library for roguelike  (Read 32752 times)

Serin Delaunay

  • Acolyte
  • *
  • Posts: 13
  • they/them/their
    • View Profile
    • itch.io
Re: BearLibTerminal: a pseudo-terminal window library for roguelike
« Reply #225 on: May 25, 2017, 09:58:25 AM »
If you have two kinds of display elements, their grid spacings are coprime, and you don't want to use a 1x1 cell size, then you can draw one kind of display element (text) grid-aligned using print() and the other kind (graphics) all at (0,0) with composition and pixel offsets.
I don't think there are any benefits to making text and graphics so mismatched in a terminal game, though.

Zireael

  • Protector of the @
  • *****
  • Posts: 602
    • View Profile
Re: BearLibTerminal: a pseudo-terminal window library for roguelike
« Reply #226 on: June 18, 2017, 07:12:40 PM »
Is there a way to get FPS when using Bearlib?

(I'm redoing Veins in Python as an exercise and Pygame performance sucks when partially transparent pictures are involved, such as isometric tiles).

Also is there a list of games using bearlib anywhere? So far I only know of unlichtwesen...

Avagart

  • 7DRL Reviewer
  • Protector of the @
  • *
  • Posts: 522
    • View Profile
Re: BearLibTerminal: a pseudo-terminal window library for roguelike
« Reply #227 on: June 18, 2017, 08:13:43 PM »
I know about Jan's (so, that guy who created Unlichtwesen) adaptation roguebasin python+libtcod tutorial to BearLibTerminal. This archive is sometimes detected as virus, but I'm pretty sure it's false positive. If you want to be 100% sure, you'd need to delete executable file that is detected as malware, python files are clean.

7DRL Poarchers will be decapitated also use BLT for display, but the official link is invalid. So, I reuploaded binaries via dropbox.

There is also small game Tiny Gatherer that use BLT; it's written in Go.
« Last Edit: June 18, 2017, 08:18:56 PM by Avagart »

AgingMinotaur

  • Protector of the @
  • *****
  • Posts: 734
  • Original Discriminating Buffalo Man
    • View Profile
    • Land of Strangers
Re: BearLibTerminal: a pseudo-terminal window library for roguelike
« Reply #228 on: June 18, 2017, 08:17:40 PM »
(I'm redoing Veins in Python as an exercise and Pygame performance sucks when partially transparent pictures are involved, such as isometric tiles).
You're not forgetting to run Surface.convert_alpha() after loading the tiles, are you? (Probably not, but I'll mention it just in case.) In my experience, python+pygame can get a bit slow, but I never had any trouble related to just loading and blitting sprites.

As always,
Minotauros
This matir, as laborintus, Dedalus hous, hath many halkes and hurnes ... wyndynges and wrynkelynges.

Cfyz

  • Bishop
  • ***
  • Posts: 190
    • View Profile
    • Email
Re: BearLibTerminal: a pseudo-terminal window library for roguelike
« Reply #229 on: June 19, 2017, 07:21:14 PM »
Quote from: Zireael
Is there a way to get FPS when using Bearlib?
Well, since BearLibTerminal uses explicit refresh (does not draw continuosly by itself, only redraws if necessary) I did not thought much about displaying FPS. Values like 0.1 would look weird =). Essentially, how frequent you call terminal.refresh() would be the FPS.
Though I do calculate it in the 'speed' entry of the SampleOmni and so does the Python port of the sample. Note that vsync is enabled by default and you need to disable it (the 'output.vsync' option) if you want more than 60-80 FPS.

Zireael

  • Protector of the @
  • *****
  • Posts: 602
    • View Profile
Re: BearLibTerminal: a pseudo-terminal window library for roguelike
« Reply #230 on: June 21, 2017, 07:55:00 AM »
Rolling along happily with BLT+Python.

One report:
Quote
The default tile alignment is “center”
(from the wiki page) doesn't seem to be true anymore, at least for the version I have via pip. I was having the tiles offset until I explicitly centered all of them.

infinity

  • Acolyte
  • *
  • Posts: 2
    • View Profile
    • Email
Re: BearLibTerminal: a pseudo-terminal window library for roguelike
« Reply #231 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.
« Last Edit: June 30, 2017, 05:37:59 AM by infinity »

Cfyz

  • Bishop
  • ***
  • Posts: 190
    • View Profile
    • Email
Re: BearLibTerminal: a pseudo-terminal window library for roguelike
« Reply #232 on: July 01, 2017, 08:53:45 PM »
Quote from: infinity
However, the function returns False regardless of whether or not the shift key is held down. <...> the function works when I set number lock off, but doesn't work when number lock is on.
I've looked into it a bit and was quite surprised by what they call Shift overriding NumLock. When you press Shift+4 you get the same scancode as when you press 4 without Shift, and what character is produced depends on the keystroke as a whole. However Shift+Numpad4 with NumLock on does not produce the scancode of the numpad key. Instead it imitates pressing the single left-arrow key by un-pressing the Shift key, sending an arrow keypress and restoring the Shift back to its original pressed state. And the system events that simulate this temporary Shift release are indistinguishable from the real key release and key press =|.

The only hint about the nature of Shift events is the inhuman speed they happen at: the Shift is released 0-2 ms before the corresponding arrow key event. Maybe I'll be able to filter  the events based on that.

P.S. I am away for about two weeks, so unfortunately I won't be able to test or fix anything in the meantime.

carterza

  • Acolyte
  • *
  • Posts: 4
    • View Profile
Re: BearLibTerminal: a pseudo-terminal window library for roguelike
« Reply #233 on: July 04, 2017, 04:59:01 PM »
Howdy - I'm new to the forums as well as bearlibterminal.

I'm trying to figure out if there is a way to call terminal_read_str and obfuscate the input, for creating something like a password input field.

I know I don't have to use terminal_read_str but I do like the cursor functionality that it exposes.

Ideally I'd like the text to appear as ***** as it's being typed, since I'm attempting to create a password field with this functionality.

Is this possible?

Thanks!

-Zachary Carter

Zireael

  • Protector of the @
  • *****
  • Posts: 602
    • View Profile
Re: BearLibTerminal: a pseudo-terminal window library for roguelike
« Reply #234 on: July 14, 2017, 09:20:47 AM »
Idly wondering if it'd be possible to combine bearlibterminal with PyQt?

denizzzka

  • Acolyte
  • *
  • Posts: 3
    • View Profile
    • Email
Re: BearLibTerminal: a pseudo-terminal window library for roguelike
« Reply #235 on: July 17, 2017, 05:32:33 PM »
Hi!

I am registerd just to ask: is mouse supported by BearLib terminal in Linux?
By default documentation says that I should see mouse cursor, but it isn't displayed, and also no mouse events captured in events cycle of my test program.

Avagart

  • 7DRL Reviewer
  • Protector of the @
  • *
  • Posts: 522
    • View Profile
Re: BearLibTerminal: a pseudo-terminal window library for roguelike
« Reply #236 on: July 17, 2017, 10:48:41 PM »
@denizzka well, I didn't try to code it myself, but mouse examples from omni-samples works flawless on Ubuntu 16.10 32bit.

@Cfyz I remember that you are planning to switch to use SDL for bearlibterminal. Does it mean that you are going to drop support for true/open type fonts?

denizzzka

  • Acolyte
  • *
  • Posts: 3
    • View Profile
    • Email
Re: BearLibTerminal: a pseudo-terminal window library for roguelike
« Reply #237 on: July 17, 2017, 11:37:46 PM »
@denizzka well, I didn't try to code it myself, but mouse examples from omni-samples works flawless on Ubuntu 16.10 32bit.

Maybe mouse events should be enabled before it can be catched?

Cfyz

  • Bishop
  • ***
  • Posts: 190
    • View Profile
    • Email
Re: BearLibTerminal: a pseudo-terminal window library for roguelike
« Reply #238 on: July 18, 2017, 04:13:39 PM »
And I am back. Mostly. Okay, in chronological order:

Quote from: carterza
I'm trying to figure out if there is a way to call terminal_read_str and obfuscate the input, for creating something like a password input field. <...> I know I don't have to use terminal_read_str but I do like the cursor functionality that it exposes.
No, the terminal_read_str function is a fairly simple wrapper over standard library input/output and its functionality is very limited. The only thing that is not directly available in API is a timed read which it uses to animate the cursor. I'll consider input obfuscation, but in the meantime it should be quite easy to write a custom read_str. Here is a simple outline for a custom read_str but without a cursor. For that you'll need to wrap the call to terminal_read, something along the lines of
Code: [Select]
int terminal_read_timeout(int timeout)
{
    for (int i = 0; i < timeout; i++)
    {
        if (terminal_has_input())
            return terminal_read();
        else
            terminal_delay(1);
    }
    return -1;
}
And flip the cursor every read that timed out.


Quote from: Zireael
Idly wondering if it'd be possible to combine bearlibterminal with PyQt?
It is hard to integrate any fairly complex custom input/output into a GUI framework, be it Qt or another one. Usually it is easier to completely rewrite one side to match the other =/.


Quote from: denizzzka
I am registerd just to ask: is mouse supported by BearLib terminal in Linux? <...> Maybe mouse events should be enabled before it can be catched?
Yes, you have to enable it explicitly. Specifically:
Code: [Select]
terminal_set("input.filter={keyboard, mouse}");
Yep, not the most intuitive part =/.


Quote from: Avagart
I remember that you are planning to switch to use SDL for bearlibterminal. Does it mean that you are going to drop support for true/open type fonts?
Nothing of the sort. The only thing I need from SDL is its cross-platform window and context management (I'll try to cut everything else away). From the user perspective transition to SDL should not even be noticeable at first. It is more about portability/stability and management costs.

denizzzka

  • Acolyte
  • *
  • Posts: 3
    • View Profile
    • Email
Re: BearLibTerminal: a pseudo-terminal window library for roguelike
« Reply #239 on: July 18, 2017, 05:13:38 PM »
Quote
Quote from: denizzzka
I am registerd just to ask: is mouse supported by BearLib terminal in Linux? <...> Maybe mouse events should be enabled before it can be catched?
Yes, you have to enable it explicitly. Specifically:
Code: [Select]
terminal_set("input.filter={keyboard, mouse}");
Yep, not the most intuitive part =/.

Works! Thanks!
« Last Edit: July 18, 2017, 05:23:54 PM by denizzzka »