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

Username:   Password: 
 RegisterRegister   
 A small text question...
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Flikerator




PostPosted: Sun Feb 13, 2005 8:32 am   Post subject: A small text question...

I want to draw text as if someone is typing it on the keyboard. So it shows up with a delay. Im going to be using Font.Draw and I want it to have a delay between each letter. I could do something like..

code:

put "h"..
delay (250)
put "e"..
delay (250)
put "l"..
delay (250)
put "l"..
delay (250)
put "o"..
delay (250)


but clearly thats not practicle. I was thinking make all the text into a string and then take it apart one char at a time and put a delay between each on. Is there anyway else to do it? (With Font.Draw)
Sponsor
Sponsor
Sponsor
sponsor
Flikerator




PostPosted: Sun Feb 13, 2005 8:51 am   Post subject: (No subject)

code:

var word, letter : string
var count : int := 0
put "Enter a word or phrase"
get word : *
cls
loop
    letter := word (length (word) - count)
    put letter ..
    delay (250)
    count := count + 1
    exit when count = length (word)
end loop


I have it typing! Yay! But its backwords...
Flikerator




PostPosted: Sun Feb 13, 2005 9:01 am   Post subject: (No subject)

Figured it out. Nobody helped me Sad

code:

var word, letter : string := "Hello"
var temp : string := ""
var count : int := 0

count := length (word)
cls
loop
    temp := temp + word (count .. count)
    count := count - 1
    exit when count = 0
end loop
loop
    letter := temp (length (temp) - count)
    put letter ..
    delay (250)
    count := count + 1
    exit when count = length (temp)
end loop


It puts the word backwrods then gets the letter one at a time lolz
Cervantes




PostPosted: Sun Feb 13, 2005 9:17 am   Post subject: (No subject)

Flikerator wrote:

Figured it out. Nobody helped me Sad

Well, you only gave us half an hour; plus, it's the morning. Confused

Instead of doing what you've got and having to cut and paste the code for each new string, make a procedure:
Turing:

procedure textDelay (text : string, timeDelay : int)
    for i : 1 .. length (text)
        put text (i) ..
        delay (timeDelay)
    end for
end textDelay
textDelay ("Hello World", 150)


Or, if you want to do it with fonts:
Turing:

var font1 := Font.New ("Arial:16")
procedure textDelayFont (text : string, x, y, font, clr, timeDelay : int)
    var xPos := x
    for i : 1 .. length (text)
        Font.Draw (text (i), xPos, y, font, clr)
        xPos += Font.Width (text (i), font)
        delay (timeDelay)
    end for
end textDelayFont
textDelayFont ("Hello World", 100, 100, font1, red, 100)
Flikerator




PostPosted: Sun Feb 13, 2005 9:37 am   Post subject: (No subject)

Quote:
Well, you only gave us half an hour; plus, it's the morning

Sry lolz, I have nothing else to do on the comp so I decided to play around with it while I waited and I figured it out, mostly.

-----------

Wow your way is much better and smaller. And you even wrote me a thing for Font.Draw! Thanks Cervantes. Now I gotta write up the storyline, add what of a movement engine I have and then then update. Thanks again![/code]
Drakain Zeil




PostPosted: Sun Feb 13, 2005 11:40 am   Post subject: (No subject)

There's nothing wrong with doing it your self, it helps you think. A majority of the time people don't explain what's happening in code (I've done it myself) and asume that you understand what is happening... but if you did, you wouldn't have the problem (well, most likely).

However, asking people for help also is good, I've been programming since I was in grade 2, however my reading skills weren't quite up to par with some of the longer words in QBasic help files. Besides, I didn't even have the internet. So for about 7 years of my programming experiance was mostly screwing around "inside of the box" because I had no one to ask for help, or challenges.
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  [ 6 Posts ]
Jump to:   


Style:  
Search: