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

Nekoninja

  • Newcomer
  • Posts: 34
  • Karma: +0/-0
    • View Profile
Re: BearLibTerminal: a pseudo-terminal window library for roguelike
« Reply #255 on: February 14, 2018, 11:52:36 PM »
I was able to get the BearLibTerminal to work with Larazus. The BearLibTerminal.pas file need one small additional. Add this "{$mode objfpc}" in before {$H+} on line 22. After this, it works beautiful. Will test it with Free Pascal and Delphi 10.2 (32 bit only since I got it free). For some reason I cannot explain why, perhaps someone can, I had to use the 64 bits BearLibTerminal.dll.

Will keep it post of my research results.
Bow to me, your evil programmer or I will destroy the internet with my 'delete' button!

Zireael

  • Rogueliker
  • ***
  • Posts: 604
  • Karma: +0/-0
    • View Profile
Re: BearLibTerminal: a pseudo-terminal window library for roguelike
« Reply #256 on: February 17, 2018, 04:09:11 PM »
Quote from: The Saber Cat
Is there a way to use fonts of two different pixel sizes as ttf imports, without converting one of them in .png? If yes, how codepoints are shared between them?
Well it is indeed hard to guess what exactly do you have trouble with, but probably you're trying to put both fonts in a single codespace, i. e. make the them all have different code points similar to font + tiles. BearLibTerminal support multiple codespaces for this purpose exactly, to have two (or more) separate fonts, with each one using the same (yet their own) code points for the same characters/tiles:

Code: [Select]
terminal.set('font: one.ttf, size=8x16')
terminal.set('another font: two.ttf, size=10x20')

Would it be possible to load the same font twice (the default one shipped with BLT), but with one of them having the codepoints overriden by tiles and the other not? Or does it have to be two different .ttf files?

Where 'another' is an arbitrary name to your liking. And then there are two ways to use it:

Code: [Select]
# Inline string formatting
terminal.puts(2, 1, 'Hello, [font=another]World')

# Global state
terminal.puts(2, 2, 'Hello, ')
terminal.font('another')
terminal.puts(2+7, 2, 'World')

BrodyDuderson

  • Newcomer
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: BearLibTerminal: a pseudo-terminal window library for roguelike
« Reply #257 on: October 01, 2018, 11:43:19 PM »
What is the best way to start printing where the last print left off? I've been using the measure function but things aren't lining up properly. I think I'm just not using it properly. Here's an example of how I've been trying to use it.

Code: [Select]
#define TEXT_WIDTH 60
#define TEXT_HEIGHT 30
#define TEXT_X ((SCREEN_WIDTH / 2) - (TEXT_WIDTH / 2))
#define TEXT_Y 2

char *awesomeText= "I don't know anything about anything. In fact, I can't even say for sure if what I just said is true; and truth be told, I'm not even sure if I can or cannot say anything for sure. I think - not know - that you should, perhaps, ignore me, maybe.";

terminal_print_ext(TEXT_X, TEXT_Y, TEXT_WIDTH, 0, 0, awesomeText);

dimensions_t mark = terminal_measure_ext(TEXT_WIDTH, TEXT_HEIGHT, awesomeText);

terminal_print_ext(mark.width, mark.height, 0, 0, 0, "[color=red]@");

When I do this, the aweomseText is wrapped correctly but the red @ is printed on the second - at "I think - not know -", rather than the end of the string.

BrodyDuderson

  • Newcomer
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: BearLibTerminal: a pseudo-terminal window library for roguelike
« Reply #258 on: October 02, 2018, 11:27:41 AM »
A somewhat related question. My "game" has color themes that the user can choose from. So for example, I do things like
 
Code: [Select]
terminal_bkcolor(activeTheme->bkColor);
Say I wanted to change the color of one of the words in awesomeText to a custom color (activeTheme->crazyColor). What would be the best way to do it?

Cfyz

  • Rogueliker
  • ***
  • Posts: 194
  • Karma: +0/-0
    • View Profile
    • Email
Re: BearLibTerminal: a pseudo-terminal window library for roguelike
« Reply #259 on: October 06, 2018, 10:24:17 PM »
Contrary to how it may look, I am not dead, yet =|.

Quote from: BrodyDuderson
What is the best way to start printing where the last print left off?
If you want to print phrase by phrase (actually more like paragraph by paragraph), then it is easy to do with measuring. Just remember that dimensions_t returned from print/measure is a size, not coordinates, so you have to add it to the last printing position. Note that print function also returns dimensions_t, you do not need a separate measure call if you've already printed the text.

However, if you want to literally continue printing, i. e. from the place of the last output symbol, there is no exact way. But I think there is no need. You can just concatenate the strings and print them in one go.

Quote from: BrodyDuderson
Say I wanted to change the color of one of the words in awesomeText to a custom color (activeTheme->crazyColor). What would be the best way to do it?
You can use some formatting tags in the string, e. g.
Code: [Select]
terminal_printf(x, y, "Some text with a [color=%d]word[/color] in another color", crazyColor); // choose %d or %s depending on the way you store the color (color_t or char*)

See terminal_print reference.

BrodyDuderson

  • Newcomer
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: BearLibTerminal: a pseudo-terminal window library for roguelike
« Reply #260 on: October 07, 2018, 01:22:38 PM »
Just remember that dimensions_t returned from print/measure is a size, not coordinates, so you have to add it to the last printing position.
What is the proper way to do this for wrapped text? Everything I've tried has been off so far and I can't figure out why.

It's true that I might not need to do this anymore, now that you made me aware of string formatting + concatenate. It would be nice to know, just in case.

Thanks for the help, and thanks for bearlibterminal. It's great.

BrodyDuderson

  • Newcomer
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: BearLibTerminal: a pseudo-terminal window library for roguelike
« Reply #261 on: December 15, 2018, 05:19:46 PM »
When I toggle into full screen, the lines for drawn boxes become really thin. Is there anyway to prevent that?

Catprog

  • Newcomer
  • Posts: 1
  • Karma: +0/-0
    • View Profile
Re: BearLibTerminal: a pseudo-terminal window library for roguelike
« Reply #262 on: December 22, 2018, 12:00:22 AM »
I have started to write a tutorial for using bearlibterminal to make a  roguelike using python. https://costumeverse.com/Tutorial/BearLibRoguelike/

Please check it out and tell me what you all think.

Daestro

  • Newcomer
  • Posts: 1
  • Karma: +0/-0
    • View Profile
Re: BearLibTerminal: a pseudo-terminal window library for roguelike
« Reply #263 on: April 20, 2019, 12:45:01 AM »
Just realized I've been using BearLibTerminal for three years now and I couldn't be happier. It feels like I've really escaped a lot of the limitations that other pseudoterminal libraries put on me.

Thank you so much for everything you do, Cfyz.

pat

  • Rogueliker
  • ***
  • Posts: 193
  • Karma: +0/-0
    • View Profile
Re: BearLibTerminal: a pseudo-terminal window library for roguelike
« Reply #264 on: April 20, 2019, 12:51:05 AM »
I’ve been using it for The Red Prison for a few months now after being a libtcod devotee for years. I had a few tough days transitioning over but it’s been fantastic overall. Now that I’ve got it working, it feels easy to use and has everything I could need for a roguelike.

NetworkingGuru

  • Newcomer
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Re: BearLibTerminal: a pseudo-terminal window library for roguelike
« Reply #265 on: April 29, 2019, 03:14:04 PM »
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).

pat

  • Rogueliker
  • ***
  • Posts: 193
  • Karma: +0/-0
    • View Profile
Re: BearLibTerminal: a pseudo-terminal window library for roguelike
« Reply #266 on: May 01, 2019, 11:39:25 AM »
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':

NetworkingGuru

  • Newcomer
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Re: BearLibTerminal: a pseudo-terminal window library for roguelike
« Reply #267 on: May 02, 2019, 06:40:30 PM »
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!

NetworkingGuru

  • Newcomer
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Re: BearLibTerminal: a pseudo-terminal window library for roguelike
« Reply #268 on: May 02, 2019, 10:11:26 PM »
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.



pat

  • Rogueliker
  • ***
  • Posts: 193
  • Karma: +0/-0
    • View Profile
Re: BearLibTerminal: a pseudo-terminal window library for roguelike
« Reply #269 on: May 03, 2019, 12:01:09 AM »
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.