Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 rolling text effect
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Prince




PostPosted: Wed May 21, 2003 5:37 pm   Post subject: rolling text effect

i looked in the text effects tutorial section already so dont bother tellin me to go there... although i did find half of wat i wanted to do
code:

proc textDelay (text : string)
    var textLetter : array 1 .. length (text) of string
    var buff : string := ""
    var font1 : int := Font.New ("Vineta BT:40")
    for i : 1 .. length (text)
        textLetter (i) := text (i)
    end for
    for t : 1 .. length (text)
        Font.Draw (textLetter (t), 50 + Font.Width (buff, font1), 200,
            font1, brightblue)
        delay (50)
        buff += textLetter (t)
    end for
end textDelay


now how can i reverse it so that it makes the letters disappear like this

H
HE
HEL
HELL
HELLO
ELLO
LLO
LO
O

basically wat im askin is is there a way for me to draw out the word one character at a time then take it away one character at a time (using Font.Draw)
Sponsor
Sponsor
Sponsor
sponsor
Solo




PostPosted: Wed May 21, 2003 6:03 pm   Post subject: Try this :)

code:
proc textDelay (text : string, x, y : int)
    var font := Font.New ("Vineta BT:40")
    var mess := text
    var move := x
    for i : 1 .. length (text)
        Font.Draw (text (i), move, y, font, brightblue)
        move += Font.Width (text (i), font)
        delay (50)
    end for
    move := x
    for i : 1 .. length (mess)
        cls
        if length (mess) > 1 then
            mess := mess (2 .. *)
        else
            mess := mess (1)
        end if
        Font.Draw (mess, x, y, font, brightblue)
        Font.Draw (text (length (text) + 1 - i), x + Font.Width (mess, font), y, font, white)
        delay (50)
        if length (mess) = 1 then
            Font.Draw (mess, x, y, font, white)
        end if
    end for
end textDelay


Is this what you wanted?

You can replace the cls with a Draw.Box, if you want to not have it take out the whole screen, there are other ways of doing this, this is prolly just the simplest.
Prince




PostPosted: Wed May 21, 2003 8:52 pm   Post subject: (No subject)

no thats not exactly wat i wanted... wen i tried to draw it out it came out wrong... its supposed to just erase the word from the beginning but leave the other stuff on the screen
hez




PostPosted: Wed May 21, 2003 11:01 pm   Post subject: here

here it isif you still need it

code:

proc rolltext (text : string)
    var len : int
    cls
    len := length (text)

    for a : 1 .. len
        put text (1 .. a)


    end for

    for a : 1 .. len

        put text (a .. len)

    end for
   
end rolltext

rolltext("HELLO")

Blade




PostPosted: Thu May 22, 2003 7:49 am   Post subject: (No subject)

i'm not sure. but i dont think thats what he wanted either. he wanted it using Font.Draw. i had to do it for my hangman game but i couldnt get the letters spaced out correctly. i dont know if there's a better way but this is what i used

code:
var x : int := 100
var font : int := Font.New ("Ariel:30")
const lett:="a"
const y := 100
procedure drawword (word : string (30), del : int)
    for i : 1 .. length (word)
        Font.Draw (word (i), x, y, font, black)
        delay (del)
        x+=Font.Width(word(i),font)
    end for
    x:=100
    cls
    for i : 1 .. length (word)
        cls
        Font.Draw (word (i .. *), x, y, font, black)
        delay (del)
    end for
    cls
end drawword

drawword ("hello", 150)
Prince




PostPosted: Thu May 22, 2003 9:45 am   Post subject: (No subject)

no thats not exactly wat i wanted either... ok ill try and write it out again... its supposed to b like this

H
HE
HEL
HELL
HELLO
..ELLO
....LLO
......LO
........O
..........

the dots represent spaces
AsianSensation




PostPosted: Thu May 22, 2003 10:09 am   Post subject: (No subject)

code:
proc textDelay (text : string)
    var font := Font.New ("Vineta BT:40")
    var x : int := 0
    for rep : 1 .. length (text)
        Font.Draw (text (rep), x, 0, font, blue)
        delay (100)
        x += 60
    end for
    x := 0
    for rep : 1 .. length (text)
        drawfillbox (x, 0, x + 60, 40, colorbg)
                delay (100)
        x += 60
    end for
end textDelay

textDelay ("Hello")


Here, Im not too sure about the spacing though, see if you can fix it
Prince




PostPosted: Thu May 22, 2003 10:17 am   Post subject: (No subject)

thnx, thats exactly wat i wanted... but now i hav another problem wher wen the font gets used too much (using Font.Draw) it reverts back to its default font... i tried using Font.Free but im not sure if it worked... can sumone tell me how to avoid this
Blade




PostPosted: Thu May 22, 2003 10:45 am   Post subject: (No subject)

ok. i fixed it. it has correct spacing and is printed how you want it.
code:
var x : int := 100
var font : int := Font.New ("Ariel:30")
const y := 100
procedure drawword (word : string (30), del : int)
    for i : 1 .. length (word)
        Font.Draw (word (i), x, y, font, black)
        delay (del)
        x+=Font.Width(word(i),font)
    end for
    x:=100
    for i : 1 .. length (word)
        Font.Draw (word (i .. *), x, y, font, black)
        delay (del)
        x+=Font.Width(word(i),font)
        cls
    end for
    cls
end drawword

drawword ("hello", 150) %first is the word, second is delay time

and why are you getting that error? i've never got one that had to do with a font
Prince




PostPosted: Thu May 22, 2003 4:18 pm   Post subject: (No subject)

im not sure y that happens with the font but if u loop it around about 80-90 times it goes back to default turing font
Blade




PostPosted: Thu May 22, 2003 7:54 pm   Post subject: (No subject)

it didnt do it with me.... must be something you have done in your program
Prince




PostPosted: Thu May 22, 2003 10:06 pm   Post subject: (No subject)

do u use v3 or v4 blade, cus i tested my program at home (with v4) and i didnt get the same error... mayb its only v3
Blade




PostPosted: Fri May 23, 2003 7:43 am   Post subject: (No subject)

probably. i use version 4.x lol. version 3 sucks RazzSmile
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 13 Posts ]
Jump to:   


Style:  
Search: