I'm using this function to draw wrapped text to the screen:
void WrapText( char Text[256], int x, int y, int Width )
{
int CurrentChar = 0;
int CursorX = x;
int LineChar = 0;
char Line[256];
while ( CurrentChar < strlen( Text ) )
{
while ( CursorX < x + Width || Text[CurrentChar] != ' ' && CurrentChar < 256 )
{
Line[LineChar] = Text[CurrentChar];
CurrentChar += 1;
LineChar += 1;
CursorX += 5;
}
dbText( x, y, Line );
LineChar = 0;
CursorX = x;
y += 15;
for ( int i = 0; i < 256; i++ )
Line[i] = ' ';
}
}
And this is the code I'm using to call it:
WrapText( "Small cracks in the rock underfoot glow with an (understandably) unearthly light.",550, 110, 110 );
Why does this happen? The problem doesn't occur if I remove the " || Text[CurrentChar] != ' ' " But I need that to make the lines break only on spaces. ><