Typewriter!

Talk about making games.

Typewriter!

Postby lcl » Thu Nov 04, 2010 4:19 pm

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
Attachments
typewriter.png
Backwards.zip
Here is fun version that allows to turn text backwards!
(232.67 KiB) Downloaded 142 times
TypeWrite.zip
Here is the file.
(195.62 KiB) Downloaded 181 times
Last edited by lcl on Wed Nov 10, 2010 7:19 pm, edited 9 times in total.
SABRE (semi-3D engine) official development topic: viewtopic.php?f=6&t=12644
A game project that utilizes SABRE: viewtopic.php?f=4&t=13297
User avatar
lcl
 
Posts: 2241
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 265 Give a positive score

Re: Type writer!

Postby Rux » Thu Nov 04, 2010 9:56 pm

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.
I'm not good at coming up with signatures...
User avatar
Rux
 
Posts: 645
Joined: Sun Apr 29, 2007 9:26 pm
Location: Sitting on your moniter invisable.
Score: 35 Give a positive score

Re: Type writer!

Postby lcl » Thu Nov 04, 2010 10:05 pm

Please download the demo. As I said in my post, that post didn't contain the actual function, its inside the zip. :D
SABRE (semi-3D engine) official development topic: viewtopic.php?f=6&t=12644
A game project that utilizes SABRE: viewtopic.php?f=4&t=13297
User avatar
lcl
 
Posts: 2241
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 265 Give a positive score

Re: Type writer!

Postby Rux » Fri Nov 05, 2010 9:44 pm

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. :)
I'm not good at coming up with signatures...
User avatar
Rux
 
Posts: 645
Joined: Sun Apr 29, 2007 9:26 pm
Location: Sitting on your moniter invisable.
Score: 35 Give a positive score

Re: Typewriter!

Postby lcl » Fri Nov 05, 2010 10:00 pm

Rux wrote:Pretty good. :)

Thanks! :D
SABRE (semi-3D engine) official development topic: viewtopic.php?f=6&t=12644
A game project that utilizes SABRE: viewtopic.php?f=4&t=13297
User avatar
lcl
 
Posts: 2241
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 265 Give a positive score

Re: Typewriter!

Postby Bee-Ant » Sun Nov 07, 2010 1:44 am

Nice :D
But you forgot to add the //comments for each code's part
to describe each function or usage ;)
User avatar
Bee-Ant
 
Posts: 3717
Joined: Wed Apr 11, 2007 12:05 pm
Location: Can bee found antywhere
Score: 210 Give a positive score

Re: Typewriter!

Postby lcl » Mon Nov 08, 2010 8:13 am

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
SABRE (semi-3D engine) official development topic: viewtopic.php?f=6&t=12644
A game project that utilizes SABRE: viewtopic.php?f=4&t=13297
User avatar
lcl
 
Posts: 2241
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 265 Give a positive score

Re: Typewriter!

Postby lcl » Mon Nov 08, 2010 1:55 pm

Comments added to the code in the main post. :D
SABRE (semi-3D engine) official development topic: viewtopic.php?f=6&t=12644
A game project that utilizes SABRE: viewtopic.php?f=4&t=13297
User avatar
lcl
 
Posts: 2241
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 265 Give a positive score

Re: Typewriter!

Postby Bee-Ant » Mon Nov 08, 2010 6:17 pm

That's more user friendly :D
User avatar
Bee-Ant
 
Posts: 3717
Joined: Wed Apr 11, 2007 12:05 pm
Location: Can bee found antywhere
Score: 210 Give a positive score

Re: Typewriter!

Postby lcl » Mon Nov 08, 2010 6:44 pm

Bee-Ant wrote:That's more user friendly :D

:D Yeah. :D
(Though it makes the code seem more complicated... :lol:)
SABRE (semi-3D engine) official development topic: viewtopic.php?f=6&t=12644
A game project that utilizes SABRE: viewtopic.php?f=4&t=13297
User avatar
lcl
 
Posts: 2241
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 265 Give a positive score

Re: Typewriter!

Postby Bee-Ant » Mon Nov 08, 2010 7:04 pm

Longer yes, complicated no :mrgreen:
(I think) :P
User avatar
Bee-Ant
 
Posts: 3717
Joined: Wed Apr 11, 2007 12:05 pm
Location: Can bee found antywhere
Score: 210 Give a positive score

Re: Typewriter!

Postby lcl » Mon Nov 08, 2010 7:09 pm

Maybe unclear is better word..? :lol:
SABRE (semi-3D engine) official development topic: viewtopic.php?f=6&t=12644
A game project that utilizes SABRE: viewtopic.php?f=4&t=13297
User avatar
lcl
 
Posts: 2241
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 265 Give a positive score

Re: Typewriter!

Postby lcl » Wed Nov 10, 2010 5:47 pm

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:
SABRE (semi-3D engine) official development topic: viewtopic.php?f=6&t=12644
A game project that utilizes SABRE: viewtopic.php?f=4&t=13297
User avatar
lcl
 
Posts: 2241
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 265 Give a positive score

Re: Typewriter!

Postby JamesLeonardo32 » Wed Nov 10, 2010 6:31 pm

Good Job lcl, and DST & BeeAnt.
JamesLeonardo32
 
Posts: 322
Joined: Wed Oct 13, 2010 4:57 pm
Score: 36 Give a positive score

Re: Typewriter!

Postby lcl » Wed Nov 10, 2010 6:57 pm

Thanks man. :D
SABRE (semi-3D engine) official development topic: viewtopic.php?f=6&t=12644
A game project that utilizes SABRE: viewtopic.php?f=4&t=13297
User avatar
lcl
 
Posts: 2241
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 265 Give a positive score

Next

Return to Game Development

Who is online

Users browsing this forum: Bing [Bot], Exabot [Bot] and 1 guest