typewriter.. text effect.

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

Apollonius(Posted 2007) [#1]
Well, I'm trying to code a type writer effect for my text. But I've ran into a small error:

parameter must be greater then 0

Once I succeed at printing all my text letter by letter on the screen if I add in a timer... I think I could create the type writer effect... What am I doing wrong guys?

Function cText(txt$,x#,y#)
	txtlen#=Len(txt$)
	
	x2#=x#
	
	For t = 0 To txtlen#
	
		txt2$=Mid(txt$,t,1)
		Text x2#,y#,txt2$,False,False
		x2#=x#+10
	
	Next
	
End Function



kfprimm(Posted 2007) [#2]
For t = 0 To txtlen#

should be,
For t = 1 To txtlen#

Just a simple mistake.


kfprimm(Posted 2007) [#3]
I just noticed,
x2#=x#+10

should be (I think),
x2#=x+((t*10)-10)



Yahfree(Posted 2007) [#4]
Heres how i would do it:

Function ComputerType(tex$,x,y,dely)

For e=1 To Len(tex$)

Text x,y,Mid$(tex$,e,1)

Delay dely

x=x+8

Next

End Function

;!@#$!@#%!^!#^#!^!^#$^#@%^#^!
;!@#%$!@%!@#$%!@#$%!@#$%!%!%!
;@#!$%@%!$%!$#%!#%!@#%!@%!#$%

;Program example:

ComputerType("Hello HAHAH i'm talking to you!!",0,0,100)


Delay 5000


the function:

ComputerType(Textyouwanttoenter$,X start pos.,ypos.,the delay on typeing 1000=1second)


Ben(t)(Posted 2007) [#5]
you could use write instead and get rid of the updating x+x+8


Yahfree(Posted 2007) [#6]
But then you cant control the Y and X pos.


Yahfree(Posted 2007) [#7]
I came up with this example for ya to study :)

Basicly gives the effect your talking to the computer..

Function ComputerType(tex$,x,y,dely)

For e=1 To Len(tex$)

Text x,y,Mid$(tex$,e,1)

Delay dely

x=x+8

Next

End Function

;!@#$!@#%!^!#^#!^!^#$^#@%^#^!
;!@#%$!@%!@#$%!@#$%!@#$%!%!%!
;@#!$%@%!$%!$#%!#%!@#%!@%!#$%

;Program example:

Graphics 800,600,16,2

ComputerType("Hello HAHAH i'm talking to you!!",0,0,100)
ComputerType("HAHAHA i'm still talking to you!!!",0,20,100)
ComputerType("You still cant do anything about it!!",0,40,100)
ComputerType("Still talking................................",0,60,100)
ComputerType("I bet your getting bored about now eh? TO BAD!!",0,80,100)
ComputerType("Lets try a input... type in your name!",0,100,100)
Print
Print
Print
Print
Print
Print
Print
Inpt$=Input()
Computertype("I'm talking to "+Inpt$+" now, How are you doing "+Inpt$+"?",0,140,100)
Print
Print
howare$=Input()
If howare$="bad"
computertype("That sucks. I'll give you 5 seconds till i turn off",0,180,100)
ElseIf howare$="good"
computertype("good for you. i'll give you 5 seconds till i turn off",0,180,100)

Else
computertype("Well thats a dumb answer, Bye bye i don't like you.",0,180,100)
End
End If


Delay 5000


Have fun.


Apollonius(Posted 2007) [#8]
does delay... delays the whole application? cuz well when the typing is done if i want things to move they wont


LineOf7s(Posted 2007) [#9]
Yes, 'Delay' delays everything.


Yahfree(Posted 2007) [#10]
i use "Delay" simply to make a "typing" effect, because if i didnt, everything would instantly appear, the delay at the end is to make the program stay up for 5 seconds, though it is a bit of a problem when you use the comand and want somthing else happening at the same time... because it delays everything untill its done typing its given string..


Apollonius(Posted 2007) [#11]
soo custom timer for delay then? :o


JA2(Posted 2007) [#12]



JA2(Posted 2007) [#13]
Here's a better example. I made these functions ages ago. You need to play about with the 'Tolerance' value to get some sentences type out properly. You could probably find a word wraping function to do it better tho :)



Hope it helps :)