typewriter.. text effect.

Blitz3D Forums/Blitz3D Beginners Area/typewriter.. text effect.

Graphics 640,480,0,2
SetBuffer BackBuffer()

Type TypeText

	Field X,Y,Letter$,Time#
	
End Type

Function TypeText (X,Y,Txt$,Space#=8,Wait#=10)

Local TT.TypeText,Time#,Gap#,A

For A = 1 To Len (Txt)

	Time	= Time + Wait
	Gap		= Gap + Space

	TT.TypeText = New TypeText
	TT\X		= X + Gap
	TT\Y		= Y
	TT\Letter	= Mid (Txt,A,1)
	TT\Time		= Time
	
Next

End Function

Function UpdateTypeText()

Local TT.TypeText

For TT.TypeText = Each TypeText
	
	TT\Time = TT\Time - 1
	
	If TT\Time <= 0
		
		Text TT\X,TT\Y,TT\Letter,True,True
			
	EndIf
	
Next

End Function

Local TxtA$ = "Hello, this is how to make typewriter text :)"

TypeText (320-StringWidth(TxtA)/2,240,TxtA,8,10)

While Not KeyDown (1)

	Cls
	
	UpdateTypeText()

	Flip
	
Wend

End