Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » textprintf_ex 'problem'

This thread is locked; no one can reply to it. rss feed Print
textprintf_ex 'problem'
Albin Engström
Member #8,110
December 2006
avatar

well, I'll probably drown with links to the manual with this question, but i'm having a really hard time navigating that 'thing'..

anyway, i'm trying to display a value with textprintf_ex but i get some problems..
here's the code:

textprintf_ex(buffer, font, 27, 32, makecol(123,50,50), -1, "X", ((cameraPOS*10+cameraEX)-mouse_y)*100);

where cameraPOS is an integred and cameraEX is float.

replacing X with %d gives me the wrong output but using &f gives me the right, problem is i don't want it to give me the output as float. i want it to cap it.
1135.99123 should be 1135. how to i accomplish this?

Thanks in advance :).

GullRaDriel
Member #3,861
September 2003
avatar

textprintf_ex(buffer, font, 27, 32, makecol(123,50,50), -1, "%d", (int)( ( cameraPOS * 10 + cameraEX ) - mouse_y ) *100 );

"Code is like shit - it only smells if it is not yours"
Allegro Wiki, full of examples and articles !!

Albin Engström
Member #8,110
December 2006
avatar

Thanks!!! i love this forum..

GullRaDriel
Member #3,861
September 2003
avatar

Heh :P

"Code is like shit - it only smells if it is not yours"
Allegro Wiki, full of examples and articles !!

Kitty Cat
Member #2,815
October 2002
avatar

Alternatively, you can use
"%.1f", ((cameraPOS * 10 + cameraEX) - mouse_y) * 100
To have it print as 1135.9. Replace the '1' in the string for however many decimal places you want.

--
"Do not meddle in the affairs of cats, for they are subtle and will pee on your computer." -- Bruce Graham

Albin Engström
Member #8,110
December 2006
avatar

thanks for the additional info ^^!

Go to: