How do I use libTCOD graphical tiles if `char` cannot fit a number >=256?

267 Views Asked by At

I am trying to add graphical tiles to my roguelike using the tcod-rs library.

The root console's put_char_ex function (or the C version, TCOD_putwchar) both take only chars. To use tiles, as per the Python tutorial, you must use tile numbers higher than 256 because the default bitmap font has 256 characters. char cannot represent these high numbers, so I'm stuck. How should I do this?

1

There are 1 best solutions below

1
On BEST ANSWER

The Console::put_char_ex method indeed takes char. However, Rust's char is not the same as C's:

char is always four bytes in size.

You should be able to fit whatever numeric value you need.


(or the C version, TCOD_putwchar)

Note that put_char_ex actually calls ffi::TCOD_console_put_char_ex; I'm not sure where TCOD_putwchar came from.