#### Archived

This topic is now archived and is closed to further replies.

# HELP WITH STRINGS...

## Recommended Posts

RegularKid    139
I am making a game and need to make a font engine with bitmaps that i have, but am not sure how to do it. Here is how I want it to look...(someone please help me translate this into real code: void PrintMessage("my text",x,y) { for(i = 0; i < length of "my text"; i++) { if(current letter is "A") { Draw bitmap of an "A" } else if(current letter is "B") { Draw bitmap of a "B" } ... } } Ok... If you understand this, please help me. I know how to draw the bitmaps, but I just need help with the string stuff and the length of the text and stuff. Please help. Thanks.

##### Share on other sites
Snyper    122
Well what you have would pretty much do the job. You could use pointers to make the PrintMessage shorter probably. Nate''s web page has some code to do what you want. Now its on OpenGL i dont know if thats ok with you or not. But the code is pretty good. Heres his site http://nate.scuzzy.net/

-Snyper

##### Share on other sites
rowbot    122

  void PrintMessage(char *mytext, int x, int y){ for(int i = 0; i < strlen(mytext); i++) { switch(mytext) { case 'A': // Draw bitmap of an "A"; case 'B': // Draw bitmap of an "B"; . . . } // Dont know if you need this but... y += widthOfLetter + widthOfSpace; }}

the switch line should have square brackets instead of angle brackets by the way. Does anyone know how to stop square brackets being replaced in this forum?

ro

Edited by - rowbot on July 23, 2000 9:25:21 PM

##### Share on other sites
HellRiZZer    308
Yeah, I have to make the same thing.. I''ll try to make and algorithm for you in Visual Basic, you just have to interpret it, ok?
So u got string
dim mystring as string
dim myletter as string
mystring = "Whatever"
you also have to dimension your surfaces as :
for y=asc("a") to asc("z")
set surface(y)=createsurfacefromfile(y & ".bmp")
next

for x=0 to len(mystring)
myletter=right$(left$(mystring,x),1)
blt to somewhere your position for x ,position for y,surface(asc(myletter)),,, and so on..
next

'' not sure here left or right first, but don''t worry too much..

That''s it! try it and comment.. If something is wrong, tell me,ok? )