Random Text effect by TinTin18th Mar 2009 16:31
|
---|
Summary Displays a random string that sorts to the desired string, like the titles effect from the Matrix movie. Description Displays a random string that sorts to the desired string, like the titles effect from the Matrix movie. Code ` This code was downloaded from The Game Creators ` It is reproduced here with full permission ` http://www.thegamecreators.com Set Display Mode 400,300,32 Sync Rate 0 : Sync On : Sync Hide Mouse Dim TXT(4) as String TXT(0)="Hello" TXT(1)="Welcome" TXT(2)="To My New" TXT(3)="Text Randomizer" TXT(4)="Matrix Effect" Do RandText(10,600,-1) Loop Function RandText(SPD,DLY,RPT) Randomize Timer() `Make Random String B$="" : For I=32 to 128 : B$=B$+Chr$(I): Next For I= 0 to 128 A=RND(96) : Repeat : B=RND(96) : Until B<>A AC$=Mid$(B$,A): BC$=Mid$(B$,B) Mid$(B$,B)=AC$ : Mid$(B$,A)=BC$ Next `Get Number of Text Strings nLine = Array Count(TXT(0)) : cLine = 0 Repeat nTxt = Len(Txt(cLine)) Dim Tag(nTXT,2) For C=1 to nTXT `Find desired character position in random string For D=1 to Len(B$) If Mid$(Txt(cLine),C) = Mid$(B$,D) then Tag(C,0)=D : Exit Next Tag(C,1) = Tag(C,0)+RND(96)` Random Start Offset Tag(C,1) = Tag(C,1) + ((Rnd(2)+1)*(96))` Random Loop Count Next `Show Characters until strings match Repeat Cls : D$="" Set Cursor (Screen Width()-(Text Width(TXT(cLine))*2))*.5,Screen Height()*.4 For D=1 to nTxt If Tag(D,1)>Tag(D,0) Then Dec Tag(D,1) If Tag(D,1)> Tag(D,0) Then Ink RGB(0,128,0),0 Else Ink RGB(128,255,128),0 E=Tag(D,1): While E>(96):E=E-(96): EndWhile A$=Mid$(B$,E) : D$=D$+A$ Print A$;" "; Next Print : Sync : Wait SPD Until Txt(cLine) = D$ Wait DLY If nLine>cLine Inc cLine Else If RPT>0 Then Dec RPT cLine = 0 EndIf Undim Tag(0) Until Inkey$()<>"" Or RPT = 0 EndFunction |