Can't display infinity symbol
Bingocat

I am just trying to display an infinity symbol for ammo in my game, but I can't get it to work. Can Allegro not display special characters like that? Here is one of the things I tried.

#SelectExpand
1string text = player.defaultWeaponNames[player.type] + ":"; 2text.push_back(char(236)); 3al_draw_filled_rectangle(cameraPos[0] + screenWidth / 2 - 100, cameraPos[1] + 5, cameraPos[0] + screenWidth / 2 + 100, cameraPos[1] + 25, al_map_rgb(255, 90, 0)); 4al_draw_rectangle(cameraPos[0] + screenWidth / 2 - 100, cameraPos[1] + 5, cameraPos[0] + screenWidth / 2 + 100, cameraPos[1] + 25, al_map_rgb(0, 0, 0), 2); 5al_draw_text(font18, al_map_rgb(255, 255, 255), cameraPos[0] + screenWidth / 2, cameraPos[1] + 5, ALLEGRO_ALIGN_CENTRE, text.c_str());

Thomas Fjellstrom

It can display non ASCII characters, but you need to use UTF-8 encoding and a font that has that character in it.

Bingocat

So would I have to do something with an ALLEGRO_USTR? Why can't it just display the character?

Elias

char(236) is -20, the range of char is -128 to 127 only. What you can do is this:

al_draw_text(..., "∞");

or

al_draw_text(..., "\u221e");

Thread #615080. Printed from Allegro.cc