DEF TYPE TSTR$ VAR TCTRL%,TCTRL2%,TCNT% DIM TARRAY$[0] IF (LEN(TSTR$) > 50) AND (INSTR(TSTR$,CHR$(10)) == -1) THEN WHILE LEN(TSTR$) > 50 FOR TCTRL%=49 TO 0 STEP -1 IF TSTR$[TCTRL%] == " " THEN BREAK NEXT PUSH TARRAY$,LEFT$(TSTR$,TCTRL%) TSTR$=RIGHT$(TSTR$,LEN(TSTR$)-(TCTRL%+1)) IF LEN(TSTR$) <= 50 THEN PUSH TARRAY$,TSTR$ WEND FOR TCTRL%=0 TO LEN(TARRAY$)-1 FOR TCTRL2%=0 TO LEN(TARRAY$[TCTRL%])-1 PRINT MID$(TARRAY$[TCTRL%],TCTRL2%,1); BEEP 9 WAIT 5 NEXT PRINT BEEP 9 WAIT 5 NEXT ELSE FOR TCTRL%=0 TO LEN(TSTR$)-1 PRINT TSTR$[TCTRL%]; BEEP 9 WAIT 5 NEXT PRINT ENDIF WAIT 10 END
Typewriter Effect with Automatic Line Break
Root / Submissions / [.]
A favorite text effect of mine is the typewriter effect, where a string is displayed one character at a time. This is easy enough to accomplish with a FOR loop, but to avoid awkward word wraps in my interactive fictions, I wrote a function to do that effect while also replacing spaces with newlines where appropriate. However, including a newline in the passed string will override the automatic line breaking.
This code was written in SmileBASIC 3 but I believe it should work without issue in SmileBASIC 4.
No posts yet (will you be the first?)
