Computer Science Canada

Scrolling text

Author:  Hack.saw [ Wed Jun 14, 2006 9:48 am ]
Post subject:  Scrolling text

hmmm... just learned how to use the Window.Whatever comands and thought they would be perfect for lets say... mission briefings. Is there any reletively easy way to get the letters to apear on the screen one at a time until the full sentance is shown? (looked in tutorials but couldnt quite find what i wanted, mabe skipped over it on acc Confused )

Author:  neufelni [ Wed Jun 14, 2006 10:53 am ]
Post subject: 

Here is a simple way to make the sentance appear one word at a time:
code:

var sentance : string := "This text should appear one word at a time."

for i : 1 .. length (sentance)
    put sentance (i) ..
    if sentance(i) = " "
        delay (500)
    end if
end for


Here is a way to make the sentance appear one letter at a time, which I think would look better for mission briefing.
code:

var sentance : string := "This text should appear one letter at a time."

for i : 1 .. length (sentance)
    put sentance (i) ..
    delay (100)
end for

Author:  Hack.saw [ Wed Jun 14, 2006 11:21 am ]
Post subject: 

Wow...so simple, cant believe i couldnt figure that out, lol. Thanks for the help Very Happy Now is there anyway to get that little flashing box that apears after the letters as thay are coming out or would you justhave to do that by making a box that flashes black/white one ahead of he text?

Author:  Bored [ Wed Jun 14, 2006 1:08 pm ]
Post subject: 

Well that would be something you yourself would have to draw as unless waiting for input from the user the cursor does not appear. I'm almost certain there is no way to make it appear that is easy and dosen't require the use to input anything.

Author:  Clayton [ Wed Jun 14, 2006 5:13 pm ]
Post subject: 

use View.Set("nocursor"), if you are having trouble with View.Set look in the Turing Walkthrough at my View.Set tut, where it is all explained Very Happy

Author:  Hack.saw [ Thu Jun 15, 2006 4:25 pm ]
Post subject: 

hehe ive read your walkthrough before learned all that stuff but thats not what we are doing here, instead of getting rid of a cursor i want to add one where there regularly wouldnt be one, but like bored said :
Quote:
that would be something you yourself would have to draw
i think that maybe the only way to get one too, was just checking to see if anybody knew any lil secret way, lol

Author:  Bored [ Thu Jun 15, 2006 5:27 pm ]
Post subject: 

Haaaaaa, I'm a genious. I found one of the few good uses for processes. I'm assuming, you are going to use Input.Pause at the end to wait for the user to continue, well Input.Pause leaves a cursor, and well just look
code:
var done := false
var continue := false
var sentance : string := "This text should appear one letter at a time."

process cursor
    loop
        Input.Pause
        exit when done
    end loop
    continue := true
end cursor

fork cursor
for i : 1 .. length (sentance)
    put sentance (i) ..
    delay (100)
end for
done := true
loop
    exit when continue
end loop

What I'm doing here is making a process that will have Input.Pasue to add the cursor, but will only exit once the text is done. Then aswell as a cursor you have your Inpu.Pause at the end as the program will not continue until the process ends (the user presses any key).

Author:  upthescale [ Thu Jun 15, 2006 7:15 pm ]
Post subject: 

and you can do it with font, but im having trouble there has tro be an easier way.. lol

code:

var sentance : string := "This text should appear one word at a time."
var font : int := Font.New ("arial:20")
var x : int := 100
for i : 1 .. length (sentance)
    %  put sentance (i) ..
    Font.Draw ("" + sentance (i), x, 200, font, 12)

    delay (60)
    x += 15
end for


Author:  Hack.saw [ Thu Jun 15, 2006 7:17 pm ]
Post subject: 

OMG! was that like some divine message you just got??? It works perfectly! Hahahahaha... I knew there had to be some lil trick you could do (there always is in programming Very Happy ) TY sooo much, lol. Would give you bits for figuring that out but dont havetoo many to give away Sad

Author:  upthescale [ Thu Jun 15, 2006 7:19 pm ]
Post subject: 

wont let me edit, but i made a cool effect, without that x variable

code:

var sentance : string := "This text should appear one word at a time."
var font : int := Font.New ("arial:20")

for i : 1 .. length (sentance)
    %  put sentance (i) ..
    Font.Draw ("" + sentance (i), i * 18, i*18, font, 12)

    delay (120)

end for


Author:  Hack.saw [ Thu Jun 15, 2006 7:20 pm ]
Post subject: 

Hehe thanks for trying "upthescale"but im just gona use the reg text since it fits mission briefing text perfectly Smile

Author:  Hack.saw [ Thu Jun 15, 2006 7:23 pm ]
Post subject: 

... you keep posting the exact same time i do... lol. Its not letting me edit either, no clue why. I like how you got it to go up at the angle like that (I could use that for a intro scene) thanks for helping me again Very Happy )

Author:  upthescale [ Thu Jun 15, 2006 8:01 pm ]
Post subject: 

ok here is some text, when it breaks that is wehen i wanan start a new line how?

code:

setscreen ("offscreenonly;graphics:600;500;position:100;100;nobuttonbar")
var Message : string := "Hello agent, I bet you are just so eager to start your mission!"
var font : int := Font.New ("arial:14")

colorback (7)
cls




for Effect : 1 .. length (Message)
    locate (12, Effect)
    color (0)
    put Message (Effect) ..

    if Effect > 40 then
        break
    end if
    delay (60)
    View.Update
end for


Author:  TheOneTrueGod [ Thu Jun 15, 2006 8:43 pm ]
Post subject: 

code:

put ""..

Author:  upthescale [ Thu Jun 15, 2006 8:46 pm ]
Post subject: 

Did not werk OneTrueGod, because the words continueson the same line, i would like so when they get to the end of the turing screen (maxx) then ther words will go on to the next line..thx

Author:  TheOneTrueGod [ Thu Jun 15, 2006 8:48 pm ]
Post subject: 

right, thats because you're using locate. Put the locate(12,1) above the for loop.

Author:  upthescale [ Thu Jun 15, 2006 8:59 pm ]
Post subject: 

Wow, you are a god thasnks

Author:  Hack.saw [ Fri Jun 16, 2006 9:46 am ]
Post subject: 

Hehe im a little bit of a noob to Forks and windows so far i have:
code:
var window1 : int
var window2 : int
var chars : array char of boolean
var done := false
var continue := false
var sentance : string := "This text should appear one letter at a time."

window1 := Window.Open ("graphics:300;200;nobuttonbar;position:top;right")
window2 := Window.Open ("graphics:300;200;nobuttonbar;position:top;left")

setscreen ("offscreenonly")
Window.Hide (window2)

process cursor
    loop
        Input.Pause
        exit when done
    end loop
    continue := true
end cursor



Window.Select (window1)
put "Transmission is, press enter to accept"
 
   
       
        fork cursor
        Input.KeyDown (chars)

if  chars (KEY_ENTER)  then
        Window.Show (window2)
        Window.Select (window2)
       
for i : 1 .. length (sentance)
    colour (10)
    put sentance (i) ..
    delay (100)
    View.Update
end for
done := true

loop
    exit when continue
end loop
    end if


Im trying to get the second window to come up with the transmission but i have never used a fork before so i think thats where my problem is...

Author:  Bored [ Fri Jun 16, 2006 10:07 am ]
Post subject: 

Well it's rather simple, just look at your code, it checks once to see if you pressed enter then exits the program. I'd sugest having Input.Pause after the transmision part, have it say any key, and get rid of the Input.KeyDown and if. alswell the first windows a bit to small on mine, the last letter goes to the next line.


: