Author Topic: Prettier Graphics with Libtcod?  (Read 27105 times)

Cfyz

  • Rogueliker
  • ***
  • Posts: 194
  • Karma: +0/-0
    • View Profile
    • Email
Re: Prettier Graphics with Libtcod?
« Reply #15 on: April 11, 2016, 12:14:13 PM »
Since we're talking about prettier graphics, I have to note that with BearLibTerminal it is easy to use square tiles alongside 'normal' rectangular fonts:
1. Choose a font so that tile size is a multiple of character size, e. g. default font is 8x16 and tiles are 16x16.
2. Load tiles to separate indices with arbitrary offset so they will not overlap with font characters, e. g. terminal.set("300: tilesets/tiles.png, size=16x16")
3. Use tile indices with the offset you just specified, e. g. healing potion is now 300+24 instead of 24.
4. Voila.

Note: tileset offsets/indices are arbitrary but they and characters are in the same code space (Unicode). As long as your game text is in ASCII, any number above 128 will do (because you will not use them for text anyway), but if you plan to use various characters like β or Ω, it is better to place graphical tiles in the special Unicode Private Use Area: 0xE000-0xF8FF.

toggle

  • Newcomer
  • Posts: 9
  • Karma: +0/-0
    • View Profile
Re: Prettier Graphics with Libtcod?
« Reply #16 on: April 11, 2016, 07:21:29 PM »
e. g. terminal.set("300: tilesets/tiles.png, size=16x16")
Wow, thanks Cfyz, that's really handy info, I'll definitely use that.
I've been trying to load different-sized tiles from multiple files but I thought it was impossible. Each time I used terminal.set() it would reset everything. I didn't know it was possible to use that extra term.

One thing I'd like to do also is load in a splash screen/image for the menu background. I managed to get it working (by loading in a giant tile) but I couldn't get it working in conjunction with my normal tiles. I guess this technique would work, unless you have a different suggestion? Libtcod has a special feature for this kind of thing. Sometimes it's really tough to figure out how to get Bearlib working, especially in Python.

though I'd suggest making a new thread about development of your game in particular (choose another appropriate board).
Do you know, should I post in 'Early Dev' or 'The Incubator' ?
« Last Edit: April 11, 2016, 07:25:08 PM by toggle »

Quendus

  • Rogueliker
  • ***
  • Posts: 447
  • Karma: +0/-0
  • $@ \in \{1,W\} \times \{1,H\}$
    • View Profile
    • Klein Roguelikes
Re: Prettier Graphics with Libtcod?
« Reply #17 on: April 11, 2016, 10:32:44 PM »
Definitely in Early Dev. The Incubator was intended for mutual support and feedback between developers working on mature projects. Now it just attracts a post every few months that would have been better placed somewhere like Announcements or Early Dev.

e. g. terminal.set("300: tilesets/tiles.png, size=16x16")
Wow, thanks Cfyz, that's really handy info, I'll definitely use that.
I've been trying to load different-sized tiles from multiple files but I thought it was impossible. Each time I used terminal.set() it would reset everything. I didn't know it was possible to use that extra term.

One thing I'd like to do also is load in a splash screen/image for the menu background. I managed to get it working (by loading in a giant tile) but I couldn't get it working in conjunction with my normal tiles. I guess this technique would work, unless you have a different suggestion? Libtcod has a special feature for this kind of thing. Sometimes it's really tough to figure out how to get Bearlib working, especially in Python.
Yes, loading different tilesets at different codepoints would let you display a splash screen or background without interfering with the normal tiles, using e.g. terminal.set("F000: tilesets/splash.png, size=640x480")