Centering letters

Blitz3D Forums/Blitz3D Programming/Centering letters

wizzlefish(Posted 2005) [#1]
Let's say I have a type called "letter" and in there, a field called "s$." If I create 10 "letter" type instances, and the field is a alphanumeric character, how would I center them on the screen, joined together as a word? They all have to be separate strings, because they are all separate entities, and they cannot be one large word string.

Thanks in advance!


n8r2k(Posted 2005) [#2]
probably do something with font size and then space it im thinkin. A while back i was semi successful with this, sorry no code- lost it


Picklesworth(Posted 2005) [#3]
There is a 2d text function called StringWidth.
That should help :)


Stevie G(Posted 2005) [#4]
String width will not help you if the letters are actual meshes though. I'd recommend using an array of types though as you can directly reference the mesh which relates to an ascii value of the character.

It really depends on how wide your meshes are .. if they are variable then simply add the meshwidth of each letter you want to print , including spaces and divide by 2.

Is there something I'm missing?


Rook Zimbabwe(Posted 2005) [#5]
whatever$="Centered on top..."
foobar$="Centered in the Middle of it all!"
text graphicswidth()/2,10,whatever$,true
text graphicswidth()/2,graphicsheight()/2,foobar$,true
input
You can writ ethe rest of the code yourself. :)

RZ