Side scrolling text function

You must understand the Game Editor concepts, before post here.

Side scrolling text function

Postby Novice » Mon Jan 15, 2007 5:45 pm

Hi everybody, I just made a function to side scroll text action movie style (take a look at the bottom of the post for a preview).
Put this code in global editor
Code: Select all
int time, blink, i;
char temp[255];
 
void type(char myText[255],int speed)
{
     if ( strcmp(&myText[i],"|")!=0  )
     {
        if (time==speed)
        {
           if (i<254&&i!=0)
           {
              strcpy(text,temp);
              strncat(text,&myText[i],1);
              strcpy(temp,text);
              strcat(text,"_");
            }
 
           else
           {
              strncpy(text,&myText[i],1);
              strcpy(temp,text);
           }
 
           time=0;
           i++;
        }
        time++;
      }
      else
      {
          if (time==speed*2)
          {
             if (blink==0)
             {
                strcpy(text,temp);
                strcpy(temp,text);
                blink=1;
             }
             else if (blink==1)
             {
                strcat(text,"_");
                blink=2;
             }
             else
             {
                strcpy(text, temp);
                blink=1;
             }
             time=0;
           }
           time++;
       }
}

In the draw event of your text actor put
Code: Select all
type("20:00\nThe North Valley\nOperation commencing|",3);

Of course change the text to suit your needs, 3 changes the scrolling speed (1 being the fastest).

You have to end a sentence with | or it will get buggy!
| represents the blinking cursor, and tells the function when to stop copying text.
To change to a new row use \n as usual.
You can add sound easily.

The code works fine but I think that it has a few bugs(ex. try leaving | out), so if anyone corrects them or optimizes the code please post it here.
I hope you find a good use for it.
Please post your opinion!
Attachments
Typing text.gif
You can see the code in action here (it doesn't loop in GE)
Why do i always get stuck?
User avatar
Novice
 
Posts: 399
Joined: Mon Aug 29, 2005 10:54 am
Location: Relative
Score: 5 Give a positive score

Postby Game A Gogo » Tue Jan 16, 2007 12:14 am

AHHHHHH
YOUR MY HERO!
Mind if i borrow?
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Postby Game A Gogo » Tue Jan 16, 2007 12:25 am

Just tried it out, works great, but you should also put that you need to insert a font and the first letter of the message (For short...)
But it works like a charm!
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Postby Novice » Tue Jan 16, 2007 1:40 pm

Game A Gogo wrote:Mind if i borrow?

Feel free :wink:
Game A Gogo wrote:but you should also put that you need to insert a font and the first letter of the message (For short...)

What do you mean by this?
Of course you have to select a font, this code is for text actors.
I put a "." so it starts displaying text, otherwise if you leave the text field empty I just shows the pacman icon regardless of the code you use (GE bug?).
This part of code is for overwriting the first letter so you can put anything (like . , _ ).
Code: Select all
           else
           {
              strncpy(text,&myText[i],1);
              strcpy(temp,text);
           }
Why do i always get stuck?
User avatar
Novice
 
Posts: 399
Joined: Mon Aug 29, 2005 10:54 am
Location: Relative
Score: 5 Give a positive score

Postby Game A Gogo » Wed Jan 17, 2007 12:13 am

well, i jsut start it whit the first character, its not a GE bug, since you cant change a normal actor to a text actor, and since there is no text triggered to the actor, so it stays the same.
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Postby Sgt. Sparky » Sat Feb 03, 2007 4:18 pm

1 + point for you!
Game A Gogo wrote:Mind if i borrow?

could I do the same? :D
did you take classes on how to script? :D

EDIT: I modified it! :D
http://game-editor.com/forum/viewtopic. ... 8696#18696
Last edited by Sgt. Sparky on Fri Apr 20, 2007 6:18 am, edited 1 time in total.
Image
Random Links:
viewtopic.php?p=19474#19474
Right now (10/14/2009) I'm working on some C++ projects, but I might be able to help if you have some Game Editor questions. :)
User avatar
Sgt. Sparky
 
Posts: 1850
Joined: Sat Oct 07, 2006 5:28 pm
Location: Somewhere out there, beneath the pale blue sky...
Score: 236 Give a positive score

Postby Novice » Sat Feb 03, 2007 9:55 pm

Borrow away. :wink:
That's why I put it here.

I didn't have any classes, but I bought a book about C and tried really hard, I'm far from finished.
Why do i always get stuck?
User avatar
Novice
 
Posts: 399
Joined: Mon Aug 29, 2005 10:54 am
Location: Relative
Score: 5 Give a positive score

Postby Sgt. Sparky » Sun Feb 04, 2007 3:26 am

:shock: what is the book called!?
*drools*
Attachments
Drool2.gif
the drool is black! Aach!
Image
Random Links:
viewtopic.php?p=19474#19474
Right now (10/14/2009) I'm working on some C++ projects, but I might be able to help if you have some Game Editor questions. :)
User avatar
Sgt. Sparky
 
Posts: 1850
Joined: Sat Oct 07, 2006 5:28 pm
Location: Somewhere out there, beneath the pale blue sky...
Score: 236 Give a positive score

Postby Novice » Sun Feb 04, 2007 7:04 pm

"The C programming language"
Why do i always get stuck?
User avatar
Novice
 
Posts: 399
Joined: Mon Aug 29, 2005 10:54 am
Location: Relative
Score: 5 Give a positive score

Postby Sgt. Sparky » Sun Feb 04, 2007 7:55 pm

wow, I should have figured thgat out :D :lol: :oops:
Image
Random Links:
viewtopic.php?p=19474#19474
Right now (10/14/2009) I'm working on some C++ projects, but I might be able to help if you have some Game Editor questions. :)
User avatar
Sgt. Sparky
 
Posts: 1850
Joined: Sat Oct 07, 2006 5:28 pm
Location: Somewhere out there, beneath the pale blue sky...
Score: 236 Give a positive score

Postby morcior » Sun Feb 04, 2007 8:14 pm

Theres a million places you can learn C online for free too sparky!

Try typing "C tutorial" into google :)

Also about equally as important for GE, I'd advise reading up on 2D vector maths.. you really only need to understand the most basic concepts like addition, subtraction, lengths, distances and trigonometry and you should find getting your games to behave as you like gets a lot easier!
morcior
 
Posts: 83
Joined: Fri Jan 12, 2007 12:16 am
Location: UK
Score: 9 Give a positive score

Postby Troodon » Sun Feb 25, 2007 3:21 pm

Novice, can I use your code too?
How can I empty and change the text? I have a text:
"Welcome" and I would like it to change when I make something.
I tried to change it with a variable
Code: Select all
if (computerDATA == 0)
{
type("Welcome|",3);
}
if (computerDATA == 1)
{
type("You've entered in the head quarters|",3);
}


but it doesn't help. Please help me.
I can't die, I already tried
~on the forums since GE 1.3.3~
User avatar
Troodon
 
Posts: 1539
Joined: Thu Jan 12, 2006 3:29 pm
Location: HELL
Score: 56 Give a positive score

Postby UltimatHedgehog » Sun Feb 25, 2007 3:35 pm

do you have something to make computerDATA ==1 you need something for example get a small thing to move left or right and set collision with it to make computerDATA = +1
Image
I always thought Hell would be a giant load screen that goes on for eternity, then one day, eons later, it would end, only to reveal a slightly different loading screen.
User avatar
UltimatHedgehog
 
Posts: 325
Joined: Fri Jan 19, 2007 1:48 pm
Location: http://downloads.khinsider.com/?u=112542 plz click
Score: 10 Give a positive score

Postby Troodon » Sun Feb 25, 2007 3:37 pm

Of course I have something to make computerDATA 1. I have also one to make it 2,3,4 etc.
:)
I can't die, I already tried
~on the forums since GE 1.3.3~
User avatar
Troodon
 
Posts: 1539
Joined: Thu Jan 12, 2006 3:29 pm
Location: HELL
Score: 56 Give a positive score

Postby UltimatHedgehog » Sun Feb 25, 2007 3:40 pm

explain what it does does it stay at welcome or skip or something
Image
I always thought Hell would be a giant load screen that goes on for eternity, then one day, eons later, it would end, only to reveal a slightly different loading screen.
User avatar
UltimatHedgehog
 
Posts: 325
Joined: Fri Jan 19, 2007 1:48 pm
Location: http://downloads.khinsider.com/?u=112542 plz click
Score: 10 Give a positive score

Next

Return to Advanced Topics

Who is online

Users browsing this forum: No registered users and 1 guest

cron