Integer blitting (text output)
GuitarGod1134

im trying to output the players health and mana for my game but according to the error in deccpp
invalid conversion from 'int' to const char*
textout_ex( buffer, font, text, x, y, color, color);
does not work with integers. so how do i print integers to the screen?

ImLeftFooted
#include <sstream>
using namespace std;

...

stringstream ss;
ss << 49;

textout_ex(buffer, font, ss.str().c_str(), x, y, color, color);

Or (because I know someone else is going to post this :P):

textprintf_ex(buffer, font, x, y, color, color, "%d", 49);

On a side note: Using the same color for fg and bg is probably not what you want. I'd recommend -1 for your bg parameter.

GuitarGod1134

I dont really understand the second function you did. I get the first 6 parameters but what are the last two? The int and ....?

CGamesPlay

Read about the printf function:
printf

ImLeftFooted

Just stick with the first solution, its better anyway.

LennyLen

You should probably read (or re-read) some tutorials on C/C++ basics as well.

Archon
Quote:

Just stick with the first solution, its better anyway.

I'd go with the second method for consistency.

Quote:

I dont really understand the second function you did. I get the first 6 parameters but what are the last two? The int and ....?

text_printf is Allegro's version of the standard printf function with extra parameters (destination bitmap, colour, position).

GuitarGod1134

Ok I read it. thx;D

Thread #590841. Printed from Allegro.cc