Computer Science Canada

Scrolling Text

Author:  endusto [ Sat Mar 05, 2005 1:47 pm ]
Post subject:  Scrolling Text

code:
var font0 : int := Font.New ("Courier New:40:bold")
var message : string := "Andrew is cool"
var messageLength : int :=length ( message ) + 1
var messagePos : int := 0
loop
if (messagePos <  messageLength) then
        Font.Draw (message (1 .. messagePos), 0, 25, font0, blue)
messagePos += 1
delay(100)
end if
end loop

Author:  [Gandalf] [ Sat Mar 05, 2005 2:45 pm ]
Post subject: 

Very nice.

But you could do it the easy way too - one letter at a time with a delay. Smile

Author:  person [ Sat Mar 05, 2005 4:58 pm ]
Post subject: 

i simplified it a little

code:

var font0 : int := Font.New ("Courier New:40:bold")
var message : string := "person is cool"
var messagePos : int
for x : 1 .. length (message)
    messagePos := x
    Font.Draw (message (messagePos), -30 + x * 30, 25, font0, blue)
    delay (100)
end for


ur code was 11 lines...mine is 8 lines without the if statement

Author:  Bacchus [ Sat Mar 05, 2005 7:34 pm ]
Post subject: 

even smaller, and could prbably be rediced moreso
code:
var font : int := Font.New ("Courier New:15:bold")
var message : string := "to keep with the trend: Bacchus is cool"
for x : 1 .. length (message)
    Font.Draw (message (x), 0+Font.Width(message(1..x-1),font), 25, font, blue)
    delay (100)
end for

Author:  endusto [ Sun Mar 06, 2005 2:20 pm ]
Post subject: 

Bacchus wrote:
even smaller, and could prbably be rediced moreso
code:
var font : int := Font.New ("Courier New:15:bold")
var message : string := "to keep with the trend: Bacchus is cool"
for x : 1 .. length (message)
    Font.Draw (message (x), 0+Font.Width(message(1..x-1),font), 25, font, blue)
    delay (100)
end for


i made it 2 characters shorted by taking out the 0+ in 0+Font.Width

code:
var font : int := Font.New ("Courier New:15:bold")
var message : string := "to keep with the trend: Bacchus is cool"
for x : 1 .. length (message)
    Font.Draw (message (x), Font.Width(message(1..x-1),font), 25, font, blue)
    delay (100)
end for



edit: i also made a horizontal scrolling text Razz
code:
setscreen ("offscreenonly")
View.Set ("graphics:800;600")
var font0 : int := Font.New ("Courier New:40:bold")
var x, y : int
x := 0
y := maxy - 40
loop
if x <= maxx then
cls
x += 1
        Font.Draw ("I dont like yams", x, y, font0, blue)
        View.Update
        delay(5)
end if
if x >= maxx then
x:= 0
end if
end loop

Author:  Bacchus [ Sun Mar 06, 2005 6:42 pm ]
Post subject: 

hm.. i dont kno y i had that zero in there, maybe starting point for text so u could start it in middle of screen etc

Author:  ssr [ Mon Mar 07, 2005 7:01 pm ]
Post subject: 

endusto wrote:
Bacchus wrote:
even smaller, and could prbably be rediced moreso
code:
var font : int := Font.New ("Courier New:15:bold")
var message : string := "to keep with the trend: Bacchus is cool"
for x : 1 .. length (message)
    Font.Draw (message (x), 0+Font.Width(message(1..x-1),font), 25, font, blue)
    delay (100)
end for


i made it 2 characters shorted by taking out the 0+ in 0+Font.Width

code:
var font : int := Font.New ("Courier New:15:bold")
var message : string := "to keep with the trend: Bacchus is cool"
for x : 1 .. length (message)
    Font.Draw (message (x), Font.Width(message(1..x-1),font), 25, font, blue)
    delay (100)
end for



edit: i also made a horizontal scrolling text Razz
code:
setscreen ("offscreenonly")
View.Set ("graphics:800;600")
var font0 : int := Font.New ("Courier New:40:bold")
var x, y : int
x := 0
y := maxy - 40
loop
if x <= maxx then
cls
x += 1
        Font.Draw ("I dont like yams", x, y, font0, blue)
        View.Update
        delay(5)
end if
if x >= maxx then
x:= 0
end if
end loop


code:

setscreen ("offscreenonly")
View.Set ("graphics:800;600")
var font0 : int := Font.New ("Courier New:40:bold")
loop
    for x : - 400 .. maxx + 400
        cls
        Font.Draw ("I don't either", x, maxy - 40, font0, brightblue)
        View.Update
        delay (5)
    end for
end loop

A little different one Very Happy

Author:  mike200015 [ Tue Mar 08, 2005 8:54 pm ]
Post subject: 

wow that last ones really nice, not 2 diffucult but looks really good Smile

Author:  Naveg [ Sun Mar 27, 2005 8:45 pm ]
Post subject: 

theyre all pretty cool, i especially like the last one

Author:  dann_west [ Mon May 02, 2005 2:15 pm ]
Post subject:  Re: Scrolling Text

Great!
if its ok i may use that idea in one of my programs!

Author:  strike_hawk89 [ Mon May 09, 2005 9:33 am ]
Post subject: 

how would u make the horizontal scrolling text to go to the next line?

Author:  Dylan-182 [ Thu May 12, 2005 2:08 am ]
Post subject: 

hey sweet scrolling txt is actually what i was looking for just now lol

Author:  MysticVegeta [ Sat May 14, 2005 5:03 pm ]
Post subject: 

eh what the hell? I cant believe i wasted my time doing this ->
code:
setscreen ("offscreenonly,nobuttonbar,position:truemiddle,centre,graphics:max;max")
var arial : int := Font.New ("arial:50:bold,italic")
var clr : int := 218
colorback (7)
cls
for s : 0 .. 19
    RGB.SetColor (clr, 0, s / 19, 0)
    Font.Draw ("Mystic pWns j0Oz @$$", (maxx div 2) - (maxx div 3), ((maxy - (maxy div 2.1)) - (s + 2)), arial, clr)
    View.Update
    delay (25)
end for

Author:  Lapsus Antepedis [ Tue May 17, 2005 7:21 am ]
Post subject: 

Add a randomized delay (within reasonable limits) and it looks like someone typing at you...
(how pointless is that?)

code:
var font : int := Font.New ("Courier New:15:bold")
var message : string := "It looks like my typing when you randomize the delay"
for x : 1 .. length (message)
    Font.Draw (message (x), Font.Width(message(1..x-1),font), 25, font, blue)
    delay (Rand.Int(10,200))
end for

Author:  gohan [ Tue May 17, 2005 10:19 am ]
Post subject: 

hey MysticVegeta..yours was pretty cool man

Author:  strike_hawk89 [ Sat May 21, 2005 1:56 pm ]
Post subject: 

how would u make the text go to the next line? If any of you have noticed, when the text goes past the window border the program doesnt stop.

Author:  Delos [ Sat May 21, 2005 3:14 pm ]
Post subject: 

You'd need to do some length calculations. Since Font.() commands render the text as a picture, you can have it return the length of a particular string in a particular font setup. Use Font.Width() to find the length of the string you're using.
Then, limit the allowed width per 'line' to the length of the screen. Figure out which letter that would be.
Cut the string up into sections and recall the 'scroll' routine on the new text.

Author:  RaPsCaLLioN [ Sat May 21, 2005 7:46 pm ]
Post subject: 

code:
var iWindow : int := Window.Open ("offscreenonly, graphics:640;200, noecho, nocursor")
var iFont := Font.New ("Courier New:40:bold")
var message : string := "WHOOOAAAAA!!!"
var rArb, rTime, j : real
loop
    rTime := Time.Elapsed / 10
    for i : 1 .. length (message)
        Font.Draw (message (i), Font.Width (message (1 .. i - 1), iFont), round (sin (Math.Distance (0, i * 2 - rTime, 128.0, 128.0) / 4.0)) * 5 + 85, iFont, blue)
    end for
    Window.Update (iWindow)
    cls
end loop


and...

code:
var iWindow : int := Window.Open ("offscreenonly, graphics:640;200, noecho, nocursor")
var iFont := Font.New ("Courier New:50:bold")
var message : string := "WHOOOAAAAA!!!"
var rArb, rTime, j : real
loop
    rTime := Time.Elapsed / 10
    for i : 1 .. length (message)
        Font.Draw (message (i), Font.Width (message (1 .. i - 1), iFont), round (sin (Math.Distance (0, i * 2 - rTime, 128.0, 128.0) / 4.0)) * 5 + 85, iFont, black)
        Font.Draw (message (i), Font.Width (message (1 .. i - 1), iFont) - 2, round (sin (Math.Distance (0, i * 2 - rTime, 128.0, 128.0) / 4.0)) * 5 + 87, iFont, white)
    end for
    Window.Update (iWindow)
    cls
end loop


: