DBPro
Here is something I made for the text adventure compo.
It prints scrolling text and wraps to the next line without chopping off word. Parameters are the text ot print, the typing delay, and the length of each line.
The function:
function PrintText(text$,waittime,linelength)
origtext$=text$
NewLine:
text$=left$(origtext$,1)
origtext$=right$(origtext$,len(origtext$)-1)
rem print each letter on one line
counter=1
repeat
print text$;
text$=left$(origtext$,1)
origtext$=right$(origtext$,len(origtext$)-1)
inc counter
wait waittime
if counter=linelength
if text$<>" "
goto FindBlank
else
counter=1
text$=left$(origtext$,1)
origtext$=right$(origtext$,len(origtext$)-1)
print " "
endif
endif
until len(origtext$)=1
goto FinishedTyping
rem search for blank
FindBlank:
repeat
print text$;
rem see if out of text
if len(origtext$)=1 then goto FinishedTyping
text$=left$(origtext$,1)
origtext$=right$(origtext$,len(origtext$)-1)
wait waittime
rem if out of room
if len(origtext$)=1 then goto FinishedTyping
until text$=" "
if len(origtext$)>1
print " "
goto NewLine
else
goto FinishedTyping
endif
FinishedTyping:
print text$ + origtext$
endfunction
And an example:
PrintText("Look at this lovely function. It has a delay time of 40 milliseconds, which is perfect, and the line wraps after about 50 characters. Note that if you set the length to 50, it will first print 50 characters, and then start looking for the end of a word so it can wrap, so if you want it to be about 50 characters, set it to 45.",40,50)
wait key
end
function PrintText(text$,waittime,linelength)
origtext$=text$
NewLine:
text$=left$(origtext$,1)
origtext$=right$(origtext$,len(origtext$)-1)
rem print each letter on one line
counter=1
repeat
print text$;
text$=left$(origtext$,1)
origtext$=right$(origtext$,len(origtext$)-1)
inc counter
wait waittime
if counter=linelength
if text$<>" "
goto FindBlank
else
counter=1
text$=left$(origtext$,1)
origtext$=right$(origtext$,len(origtext$)-1)
print " "
endif
endif
until len(origtext$)=1
goto FinishedTyping
rem search for blank
FindBlank:
repeat
print text$;
rem see if out of text
if len(origtext$)=1 then goto FinishedTyping
text$=left$(origtext$,1)
origtext$=right$(origtext$,len(origtext$)-1)
wait waittime
rem if out of room
if len(origtext$)=1 then goto FinishedTyping
until text$=" "
if len(origtext$)>1
print " "
goto NewLine
else
goto FinishedTyping
endif
FinishedTyping:
print text$ + origtext$
endfunction
Enjoy.
Uncle Sam
Nvidia Geforce 7600 GS 256MB PCIEx, 2.66 GHZ Pentium 4 proccessor, 768MB RAM
Need particles? Click
here!