Page 1 of 3

Typewriter!

PostPosted: Thu Nov 04, 2010 4:19 pm
by lcl
Hello! :D

Yeah, I know, there is so much typewrite codes around...
But I wanted to share my own version with you!
I made it by looking at pyrometal's code and when I understood how
it works, I built my own, shorter version. :D

- Speak is variable where function stores the line.
- type is variable that is used to store characters into
text actor.
- counter is variable that holds the amount of
characters printed.

The code:
Code: Select all
char Speak[200] = " "; //Create variables
char type[200] = " ";
int counter;

void message(char Line[200]) //Create function
{
    int i; //Create integer called i
    int limit = strlen(Line); //Create integer called limit and make it equal to string length of "Line"
 
    for (i = 0; i <= 199; i ++) //Reset strings and counter
    {
        Speak[i] = NULL;
        type[i] = NULL;
        counter = 0;
    }
 
    for (i = 0; i < limit; i ++) //Store "Line" to "Speak"
    {
        Speak[i] = Line[i];
    }
}

Add this code to text actors draw actor event:
Code: Select all
if (counter < strlen(Speak))
{
    type[counter] = Speak[counter]; //Store "Speak" characters to "type" one by one
    sprintf(text, type); //Print "type"
    counter ++; //Increase counter
}


Sorry for that there's no comments in the zip file. =P

I want to thank pyrometal for sharing codes of his typewriter engine. It helped me alot. =) Also thanks to DST and Bee-Ant for sending me their typewriter engines. =)
Tell me what you think! :D

EDIT: Added little thing that turns written text backwards... :D

Re: Type writer!

PostPosted: Thu Nov 04, 2010 9:56 pm
by Rux
You should also define the variables that are needed in it, because I don't know which ones iare an integer and what ones are a string or something else.

Re: Type writer!

PostPosted: Thu Nov 04, 2010 10:05 pm
by lcl
Please download the demo. As I said in my post, that post didn't contain the actual function, its inside the zip. :D

Re: Type writer!

PostPosted: Fri Nov 05, 2010 9:44 pm
by Rux
lcl wrote:Please download the demo. As I said in my post, that post didn't contain the actual function, its inside the zip. :D

Oh, I must have saw this post before the demo was up. I'll download it now.

EDIT: Pretty good. :)

Re: Typewriter!

PostPosted: Fri Nov 05, 2010 10:00 pm
by lcl
Rux wrote:Pretty good. :)

Thanks! :D

Re: Typewriter!

PostPosted: Sun Nov 07, 2010 1:44 am
by Bee-Ant
Nice :D
But you forgot to add the //comments for each code's part
to describe each function or usage ;)

Re: Typewriter!

PostPosted: Mon Nov 08, 2010 8:13 am
by lcl
Bee-Ant wrote:But you forgot to add the //comments for each code's part
to describe each function or usage ;)

Oh yeah... :oops: I'll add those later today. :D

Re: Typewriter!

PostPosted: Mon Nov 08, 2010 1:55 pm
by lcl
Comments added to the code in the main post. :D

Re: Typewriter!

PostPosted: Mon Nov 08, 2010 6:17 pm
by Bee-Ant
That's more user friendly :D

Re: Typewriter!

PostPosted: Mon Nov 08, 2010 6:44 pm
by lcl
Bee-Ant wrote:That's more user friendly :D

:D Yeah. :D
(Though it makes the code seem more complicated... :lol:)

Re: Typewriter!

PostPosted: Mon Nov 08, 2010 7:04 pm
by Bee-Ant
Longer yes, complicated no :mrgreen:
(I think) :P

Re: Typewriter!

PostPosted: Mon Nov 08, 2010 7:09 pm
by lcl
Maybe unclear is better word..? :lol:

Re: Typewriter!

PostPosted: Wed Nov 10, 2010 5:47 pm
by lcl
Added little fun thing that works like turning you text backwards.
Like this:

You write: Wow! Cool!
And that's what comes out: !looC !woW

:lol:

Re: Typewriter!

PostPosted: Wed Nov 10, 2010 6:31 pm
by JamesLeonardo32
Good Job lcl, and DST & BeeAnt.

Re: Typewriter!

PostPosted: Wed Nov 10, 2010 6:57 pm
by lcl
Thanks man. :D