I am just being introduced into the allegro game library, and I'm making a simple program.

My problem is confusing me horribly. I'm using the textout_ex code, but what I want to do is display 2 pieces of info in one textout function.

Like:
textout_ex(screen, font, "hello" AND MyVariable , 480, 685, Green, -1 );

But I can not get this to work. I would think it would be a simple solution but I can't find the answer. Can you help?

my code:

textout_ex( screen, size3font, MyPercent + "%" , 480, 685, makecol(57, 57, 57), -1 );

Recommended Answers

All 6 Replies

Use sprintf() to print your fancy formatting to a buffer.
Pass that buffer to your primitive textout.

Use sprintf() to print your fancy formatting to a buffer.
Pass that buffer to your primitive textout.

Thanks. also, is there a better way to print out stuff to allegro besides using textout_ex?

It seems like textout_ex is going to thoroughly p*ss me off seeing as how specific if you have be to make it work.

Thanks. also, is there a better way to print out stuff to allegro besides using textout_ex?

It seems like textout_ex is going to thoroughly p*ss me off seeing as how specific if you have be to make it work.

Wrong attitude. It's specific because it needs to be. Once you understand what it needs it's a no brainer to give it what it wants.

And if not being able to pass char* + int / double in a single function parameter is going to p*ss you off, maybe there's still room in shop class :icon_twisted:

Wrong attitude. It's specific because it needs to be. Once you understand what it needs it's a no brainer to give it what it wants.

And if not being able to pass char* + int / double in a single function parameter is going to p*ss you off, maybe there's still room in shop class :icon_twisted:

ok. where should I go to be able to understand this stuff? I'm use to cout statements were you can say

cout << string << "hello has" << int << "characters." << string2;

Without being able to do that, coding seems extraordinarily more time consuming.

isn't there any way I can do the above code in allegro format?

Thanks :)

Yes, you create a simple wrapper class which inherits cout, so you can chain all those << << things together.

Then in the end, you call textout

Simple!

If you understand Salem's idea, do it.

Otherwise, sprintf() will do what you want very simply. You can merge a string with an int

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.