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

Username:   Password: 
 RegisterRegister   
 Typewriter Effect in Turing
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Tasty Pastry




PostPosted: Fri May 19, 2017 10:00 pm   Post subject: Typewriter Effect in Turing

I'm trying to make a game in Turing, and I want to have an option to speed up the text as its appearing across the screen. I've been able to speed up the text, but only after another line has started. Is it possible to have it speed up whenever the user presses down a key?

Turing:


var chars : array char of boolean

proc TypewriterPrint(text : string)
loop
Input.KeyDown (chars)
 if chars (KEY_ENTER) then
  for i : 1..length(text)
    delay(50)
    put text(i) ..
  end for
  put ""
else
for i : 1..length(text)
  delay(100)
  put text(i) ..
 end for
 put ""
end if
end loop
end TypewriterPrint

TypewriterPrint("This will be printed like a typewriter")



Sorry if my code is a little messy, I'm still learning the ins and outs of Turing.

Please specify what version of Turing you are using
4.11
Sponsor
Sponsor
Sponsor
sponsor
Insectoid




PostPosted: Sun May 21, 2017 1:33 pm   Post subject: RE:Typewriter Effect in Turing

If you want to change the speed on a per-letter basis, then maybe you should put the code that decides the speed in the same loop as the code that prints the letters. You code is currently formatted as follows:

code:

loop
   %decide speed
   for each letter
       print letter
       delay (speed)
  end for
end loop


You should re-format it as follows:

code:

loop
    for each letter
        %decide speed
        print letter
        delay (speed)
   end for
end loop
Tasty Pastry




PostPosted: Sun May 21, 2017 2:11 pm   Post subject: Re: RE:Typewriter Effect in Turing

Insectoid @ Sun May 21, 2017 1:33 pm wrote:

You should re-format it as follows:

code:

loop
    for each letter
        %decide speed
        print letter
        delay (speed)
   end for
end loop


Thank you so much! It works now.
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  [ 3 Posts ]
Jump to:   


Style:  
Search: