I'm using allegro to make my own version of pong, and I want the score to be kept track everytime it hits the paddle. So I have points++; for keeping track of points, but it won't print in textout_ex. Is there another print/textout function in allegro to print variables? I did not find anything in a search.
this doesn't work
textout_ex(screen, font, points, 250, 250, makecol(0, 0, 0), makecol(0, 0, 0));
Have you tryed to use as 3rd variable a text variable instead a numeric one?
that still didnt work. It still ends up saying i need "something" instead of a variable inside textout.
Here's a bright idea, post the exact error message! Instead of having us figure it out.
don't have to be a jerk about it, just ask.
Originally Posted by Sentral
240 C:\Dev-Cpp\Codex\Pong\Pong.cpp invalid conversion from `int' to `const char*'
240 C:\Dev-Cpp\Codex\Pong\Pong.cpp initializing argument 3 of `void textout_ex(BITMAP*, const FONT*, const char*, int, int, int, int)'
Maybe this: http://www.die.net/doc/linux/man/man3/textout_ex.3.html
I'm guessing your 'points' is of type int, which cannot be used for the third parameter. The error is basically telling you what to fix.
PS: Perhaps you should have not been a lazy poster, and you wouldn't have gotten a jerk remark.
even if points is changed to a const char* variable it still won't run correctly. Windows will say an error has occured and close the program. I just want to know if there is another function like textout_ex that I can use to display variables, specifically ints/doubles.
> don't have to be a jerk about it, just ask.
He shouldn't need to ask, if you'd asked a smart question in the first place.
There shouldn't be any problem with the code I posted, I imagine you have something like:
Because you haven't posted any piece of code I'm assuming that you use doublebuffering for drawing it all, so don't draw the text directly to the 'screen' default bitmap.
static int points=0;
function drawpoints(BITMAP screenbuffer)
A second thing, read the Allegro documentation, in the function call you posted you are using black text with black background... I think you won't see the points with that color combination.
If your program still crashes the problem should be from other part, not this one (I suppose).