Closed Darky-Lucera closed 4 years ago
I checked the error. It looks like the tile you're trying to assign is out-of-bounds. It might be useful show the parameters given to tcod.tileset.load_tilesheet
.
I'm pretty sure they are 'out of bounds' (of a vector/array) because the texture is 320x80 pixels (32x8 tiles), and the unicode values are > 256.
I want to remap Unicode values for some glyphs that I want to use for message internationalization:
tileset.remap(ord('Ñ'), 26, 3)
Tile x=26, y=3 is inside the texture.
My thought is that libtcod (C) is using some kind of map<codepoint , position> being codepoint = unicode value and position = x + y*columns, so we can use whatever value as codepoint while the position tile is inside the texture.
Is there another way to render python strings with glyphs like: Ñ, Ç, Á, È, Ψ, ж, ... ("España") like we were able to do with the old API?
Here are the initialization values (old and new):
tcod.console_set_custom_font('arial10x10.png', tcod.FONT_TYPE_GREYSCALE | tcod.FONT_LAYOUT_TCOD)
tileset = tcod.tileset.load_tilesheet('arial10x10.png', 32, 8, tcod.tileset.CHARMAP_TCOD)
It worked fine with the old API.
I was able to recreate the error. The codepoint and the tile index got swapped when remap called the C function. I'll release a fix now.
Version 11.15.3
is deploying now. It also has a better error message when things go wrong.
Nice!
I'm a python newcomer (only some AI stuff and now your fantastic roguelike tutorial). When will it be available from PIP? Does it needs some kind of approval?
BTW, I really enjoyed the revised tutorial (I didn't want to wait some weeks to have all chapters, so I did the old version). And now revisiting the new tutorial I have realized about the new API and the new features of Python 3.7+. For this reason I wanted to modernize my roguelike source code.
It's quite fast
I'm trying to modernize my roguelike game to use new API, like contexts, tilesets, etc. But I have had a problem trying to redefine unicode values.
For instance, where I was doing:
tcod.console_map_ascii_code_to_font(ord('Ñ'), 26, 3)
now I'm trying to do:
tileset.remap(ord('Ñ'), 26, 3)
but I'm getting the error:
Is there a way to do what I'm trying to do?
I was using it also to define ids for my sprites. For example:
tileset.remap(300, 0, 5) # Hero
300 is an unicode value that I know that I don't want to use: ĬNote: For loading the tileset I'm using tcod.tileset.load_tilesheet(...) and in the old code I was using tcod.console_set_custom_font(...)
Thanks in advance!