Text wrap by Anonymous Coder7th Apr 2009 8:49
|
---|
Summary This is a modified version of a function by Benzoate. I have added a little code so the function now does not split a word at the end of a row. The word now moves to the next line. Description This is a modified version of a function by Benzoate. I have added a little code so the function now does not split a word at the end of a row. The word now moves to the next line. Code ` This code was downloaded from The Game Creators ` It is reproduced here with full permission ` http://www.thegamecreators.com function wText(x#, y#, s$, length#) if len(s$) < length# text x#, y#, s$ s$="" endif space_count=length# wcount=1 while len(s$) > length# wtextT$ = left$(s$, length#) rem New piece of code to check where the last space exists in the current line. The length# value is replaced from this point rem with a new value that takes away the number of characters back to the previous word. This removes words being split at the end of a line. for f = space_count to 1 step -1 if mid$(wtextT$,f)=" " then space_count=space_count-(space_count-f):goto skip9 next f skip9: wtextT$ = left$(s$, space_count) s$ = right$(s$, len(s$)-space_count) text x#, y#+text height(s$)*wcount, wTextT$ wcount=wcount+1 space_count=length# endwhile text x#, y#+text height(s$)*wcount, s$ x#=0 y#=0 s$="" length#=0 endfunction |