bbText could write interger/float on screen?

Archives Forums/Blitz3D SDK Programming/bbText could write interger/float on screen?

MeowZ(Posted 2007) [#1]
I've try this

int mouseX,mouseY;
mouseX = bbMouseX();
mouseY = bbMouseY();
bbText (0,0,mouseX);
bbText (0,20,mouseY);

it did not work because bbText, bbPrint, bbWrite accept only text parameter. anyone coule help? thank you.


ninjarat(Posted 2007) [#2]
Try converting it over to a string then first. What language are you using?


Barnabius(Posted 2007) [#3]
I am not using C but in EBasic or PowerBasic I'd use:

bbText(0,0,str$(mouseX))
bbText(0,20,str$(mouseY))

or:

bbText(0,0,"MX: "+str$(mouseX)+" MY: "+str$(mouseY))

str$ translates a number into a string. I am sure you can use a C equivalent.

Barney


MeowZ(Posted 2007) [#4]
ar... I've finished it up with something like this

int mouseX,mouseY;
char buff[10] ;

mouseX = bbMouseX();
mouseY = bbMouseY();

bbText(0,20,"Mouse X:");
bbText(100,20,itoa(mouseX,buff,10));

bbText(0,40,"Mouse Y:");
bbText(100,40,itoa(mouseY,buff,10));

however, I cannot combine text and converted text into one command. thank you guys,


MCP(Posted 2007) [#5]
MeowZ you can combine text and converted text with the C function:- sprintf()

useage: sprintf( buff, "%s %d", "Mouse X:",mouseX);

Check your C documentation for details :)

Cheers,

Roy


MeowZ(Posted 2007) [#6]
Hi Roy,

We cannot use ?printf() to print text on Blitz3d. - -a
in B3D window, must use bbText.

thank you,


MCP(Posted 2007) [#7]
Hi MeowZ,

sprintf() is a C string formatting function - it does'nt print anything!
If MouseX=100 then the output for my above example would store the formatted text "Mouse X: 100" in the buffer you declared as char buff[10] though you would have to increase the size of that buffer to something larger.
You would then print the text using bbText(0,20,buff)

Cheers,

Roy


MeowZ(Posted 2007) [#8]
Oh..yessssss
Thank you very much, Roy.