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

NetworkingGuru

  • Newcomer
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Re: BearLibTerminal: a pseudo-terminal window library for roguelike
« Reply #270 on: May 03, 2019, 03:23:48 PM »
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

NetworkingGuru

  • Newcomer
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Re: BearLibTerminal: a pseudo-terminal window library for roguelike
« Reply #271 on: May 20, 2019, 09:06:57 PM »
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.

Omnivore

  • Rogueliker
  • ***
  • Posts: 154
  • Karma: +0/-0
    • View Profile
Re: BearLibTerminal: a pseudo-terminal window library for roguelike
« Reply #272 on: July 26, 2019, 12:41:04 AM »
Back after 3 years! 

Just a note if you are using BearLibTerminal in Python and the PyCharm IDE:

If you add BearLibTerminal to your Python 3.x installation via 'python -m pip install BearLibTerminal'
you'll find some oddball behavior in importing it especially in a PyCharm project.  The easiest fix
I've found is simply to use the following import statement:
Code: [Select]
from bearlibterminal import terminal as bltand then if/when PyCharm shows an error on terminal, just right click and tell it to ignore it.

I believe the problem is with PyCharm's overly strict interpretation of Python syntax and import behavior.

Hope this helps,
Brian aka Omnivore

PS: I was being an idiot - had multiple possible imports from old install and used Pascal casing *gah*
« Last Edit: July 26, 2019, 02:26:05 AM by Omnivore »

Omnivore

  • Rogueliker
  • ***
  • Posts: 154
  • Karma: +0/-0
    • View Profile
Re: BearLibTerminal: a pseudo-terminal window library for roguelike
« Reply #273 on: August 01, 2019, 11:04:03 PM »
Has anyone done a CFFI wrapper for BearLibTerminal with PyPy? 

The ctypes interface is rather slow with the PyPy JIT.  I'm doing a variant on the Python Roguelike Tutorial and at equivalent of step 3 in the libtcod tutorial, repeat key can outrun the game loop and fill the input to where you get a bunch of moves after you release the movement key. 

Haven't profiled it yet, nor taken steps to remove unnecessary calls to (for example) terminal.color or buffered rows as text with color markers, etc - all of which would help if ctypes is indeed the culprit and a CFFI wrapper isn't commonly available. 

Of course all this assumes I finish writing the tutorial- for personal use an existing CFFI wrapper would save me some time and most likely a bit of head scratching.

Thanks,
Omnivore

dividee

  • Newcomer
  • Posts: 4
  • Karma: +0/-0
    • View Profile
    • Email
Re: BearLibTerminal: a pseudo-terminal window library for roguelike
« Reply #274 on: September 04, 2019, 06:38:07 PM »
Has anyone done a CFFI wrapper for BearLibTerminal with PyPy? 

Sorry for the late reply. I did a CFFI wrapper for bearlibterminal a while ago, but never published it. I just uploaded it, if you want to try it out.
https://github.com/ibatugow/blt_samples/blob/master/Python/bearlibterminal/terminal-cffi.py

Just replace terminal.py with the cffi version and it should work. It's only a little faster in CPython, but vastly faster in pypy.

vioagatha

  • Newcomer
  • Posts: 1
  • Karma: +0/-0
  • MegaQQ
    • View Profile
    • DominoQQ
Re: BearLibTerminal: a pseudo-terminal window library for roguelike
« Reply #275 on: December 03, 2019, 08:31:09 AM »
Is there any possibility of compiling this for mac as well? Would any changes to the source code be required?
help to see my profile http://27.124.27.111/  ;D ;D ;D ;D

gyrobone

  • Newcomer
  • Posts: 1
  • Karma: +0/-0
    • View Profile
Re: BearLibTerminal: a pseudo-terminal window library for roguelike
« Reply #276 on: March 14, 2020, 05:42:01 PM »
This may be a strange question, but hopefully someone can give me a hand. I am currently using bearlibterminal to create a game, but I'm not making a roguelike game. I want to make a text based adventure game, and i really like blt's user input handling and it's simplicity. But I was wondering if there was a way to draw more than just tile- or cell-based objects like characters and sprites.

TL;DR
Is there was a way to output more complicated shapes, such as sine waves or circles, to the terminal?

I understand that this probably wasn't the intented use for blt, but I thought it was worth a shot to ask.

pat

  • Rogueliker
  • ***
  • Posts: 193
  • Karma: +0/-0
    • View Profile
Re: BearLibTerminal: a pseudo-terminal window library for roguelike
« Reply #277 on: March 14, 2020, 10:38:53 PM »
It's probably not easily suited to that but there's two possible ways:

1. Implement a font made up of a wide range of pieces which could be put together by the game to resemble that data. That might work for circles and static content like that but it would have some real problems with things like sine waves and at best you'd probably have to only display an approximation of the data. I don't think this would be the best approach.

2. Implement a font made up of a single large character and update this every time you need it to display a custom image. For instance, I use this approach for my mini map - I build an x, y array of pixels based off my map data and what's been explored by the player, write that array to a png file every turn, update the custom font every turn and then display that large single character as the map. It's not the most efficient method but it works. I do a similar thing for my title screen where I display an image which covers the whole screen.