Main Menu

scroll text problem

Started by philathome, October 26, 2010, 04:13:42 AM

Previous topic - Next topic

philathome

i have a scroll text function but whot i am trying to do is when the last letter shows on screen
scroll back the other way to the first letter shows on screen and so on but i can
not get my head round it

text$="Hallo Playbasic Fans How Ya All Doing This Fine Day"
do
cls
s=scrolltext(50,100,300,text$,s,1)

loop
function scrolltext(y#,lx#,rx#,text$,s,spd)

x1#=rx#
x1#=x1#-s
for ch#=1.0 to len(text$)
if x1#<=rx#
if x1#>lx#
text x1#,y#,mid$(text$,ch#)
endif
endif
x1#=x1#+gettextwidth(mid$(text$,ch#))
next ch#
if x1#<=rx#
s=0
endif
s=s+spd
sync

endfunction s


kevin




ext$="Hallo Playbasic Fans How Ya All Doing This Fine Day"
Length_IN_Pixels=GetTextWidth(ext$)

Xpos=800
Direction=-1

Do
Cls
Text Xpos,100,ext$
Xpos+=Direction
if Xpos<-(Length_In_Pixels+200) then Direction*=-1
if Xpos>1000 then Direction*=-1

Sync
loop


philathome

thank you but thats not realy who't i am trying to do
when the last letter is showing on the screen if the the first letter is of the screen it will scroll back to show the the start
and go back and forth with in the start and finish lx# and rx# i hope i have been able to explain my self a little more clearly

kevin




ext$="Hallo Playbasic Fans How Ya All Doing This Fine Day"
Length_IN_Pixels=GetTextWidth(ext$)

Xpos=800
Direction=-1

Do
Cls
Text Xpos,100,ext$
Xpos+=Direction
if Xpos<(800-Length_In_Pixels) then Direction*=-1
if Xpos>800 then Direction*=-1

Sync
loop





philathome

thank you that's great you make it look so easy

kevin


No probs,  Here's a version that's based upon time, rather than the frame rate.  





ext$="Hello Playbasic Fans How Ya All Doing This Fine Day..."

; Size of the message in pixels
Length_IN_Pixels=GetTextWidth(ext$)

; Time the message takes to move on/off in milliseconds
Duration = 5000

; Get the time when this loop starts
StartTime=Timer()
Do

; Clear the Screen
Cls

; calc the time past since the loop started running (in milliseconds)
TimePast=Timer()-StartTime

; Calc the Millisecond/Position With the time period
Tick=Mod(TimePast,Duration)

; convert the position within the time period into an angle
Angle#=180.0*(Tick/float(Duration))

; plot it with sinus
Text 800-SinRadius(Angle#,Length_In_Pixels),100,ext$

print Fps()

Sync
loop