Text Scrolling
Displaying 1-20 of 20 total.
1
Please enter a numerical value for the importance of this sticky.
Enter 0 to unsticky.
spaceseel

I don't know how to scroll the letters letter-by-letter like you would expect to see in a lot of console RPG games. Would anyone have any idea how you would go doing this?

Posted on 2007-01-28 16:44:15

Gayo

Well, anything that you want to happen gradually can be handled with a loop based on timer. There are a few ways to do this -- you can just loop as long as you want to display the thing and have the written text be a function of the timer, or you can increment some sort of counter X times per second and make the number of letters displayed a function of the counter. Either way you should make the interval variable- or define-based so you can change it.
To actually display the growing string you need to use the substring functions. Either you can use left() to get successively larger piece of the string, or if you want to save some cycles you can use mid() to get one letter at a time and blit it to an image buffer, then draw the buffer. I'm going to make a generic messagebox lib using this latter method someday.

Posted on 2007-01-28 21:31:26

mcgrue

Do the textboxes in Sully do what you want?

Posted on 2007-01-29 14:14:45

IkimashoZ

Here's how I accomplish this in Kambou:


printstring(x1, y1, screen, world_font_white,
left(tutorial_events[adv][6], story_timer - adv_time));

printstring(x1, y1+18, screen, world_font_white,
left(tutorial_events[adv][7], story_timer - adv_time - len(tutorial_events[adv][6])));

printstring(x1, y1+36, screen, world_font_white,
left(tutorial_events[adv][8], story_timer - adv_time - len(tutorial_events[adv][6])
- len(tutorial_events[adv][7])));

printstring(x1, y1+54, screen, world_font_white,
left(tutorial_events[adv][9], story_timer - adv_time - len(tutorial_events[adv][6]) -
len(tutorial_events[adv][7]) - len(tutorial_events[adv][8])));


There are four lines of text that can fit in a textbox, so you just subtract the length of previous lines from the offset variable of left for all subsequent lines.

adv is the current "frame" of the story

adv_time is the amount of time that has passed since the box was first displayed

story_timer counts the time since the story began

Hope this helps!

Posted on 2007-01-29 21:04:43 (last edited on 2007-01-29 21:06:00)

spaceseel

Quote:Originally posted by mcgrue

Do the textboxes in Sully do what you want?


Sort of like that. But I'm trying to do it in 640x480 mode. I plan to have the name of the character show first with it's own text and then the message would show.
_____________________________________
|Spaceseel: |
| This is just the style I would want |
| for a message box |
| |
| \/ |
----------------------------------------------------------------

I'll try to figure it out on my own based on what you guys already told me. I already have created a function that is used to create a box based off the dimensions I give it. It is totally code drawn. It has a 2 pixel thick border with a beveled look and also made it so that the fill was transparent.

If I need any help on any part, then I'll just ask you. Thanks

Posted on 2007-01-31 11:35:57 (last edited on 2007-01-31 11:37:54)

spaceseel

I'm now trying to do simple rendering of the text boxes. I'm using the RectVGrad feature from the code vault and it looks cool. But the thing is, when I used the following code below, it changed from transparent to fully visible. I'm trying to get it to stay transparent, but so far unsuccessful.

while(!b1)
{
DrawSystemBox(10,330,630,470);
EnableVariableWidth(mbNameFnt);
EnableVariableWidth(stringFnt);
Render();
PrintString(12,332,screen,mbNameFnt,mbName);
PrintString(25,355,screen,stringFnt,mbText);
ShowPage();
}


I created a command called, "DrawSystemBox", it allows you to create a standard textbox with the gradient features in it. It creates the gradient box with transparency set to 20 and 60. And it also draws a 2 pixel thick line as a border. Just be aware that this code is temporary until I add in the scrolling features to it.

Posted on 2007-02-09 01:21:42 (last edited on 2007-02-09 01:24:48)

Overkill

Hm, did you make sure the alpha arguments (a1 and a2) were equal? Otherwise, you could tweak remove the use of those arguments from RectVGrad(), and just SetLucent() before drawing the rectangle.

Especially recommended since the next public release (or SVN release) has RectVGrad built-in as:
void RectVGrad(int x, int y, int x2, int y2, int color, int color2, int dest);

EDIT: Oh wait, you WANT it to be more opaque on one part of the rectangle than the other but it's not lucent. In that case, show me how you call RectVGrad. Or I misunderstand.

Posted on 2007-02-10 03:35:10 (last edited on 2007-02-10 03:38:51)

spaceseel

Quote:Originally posted by Overkill


Oh wait, you WANT it to be more opaque on one part of the rectangle than the other but it's not lucent. In that case, show me how you call RectVGrad. Or I misunderstand.


No, it seems like if I were to put it into the place that I have it now, then it doesn't become transparent. But If I were to take it out of the while loop, then when I load a second message box, the first one somehow doesn't get deleted and they sort of layer one another. I just don't think that the first one gets removed from the screen. In this case how would you go getting rid of the first one so there isn't any layering.

Posted on 2007-02-10 13:42:21 (last edited on 2007-02-10 13:44:47)

Overkill

Hm, sounds like you're not clearing the screen before you draw over it? ShowPage() doesn't do it, and Render() only clears the screen if a map's loader. To clear the screen to black use this:
RectFill(0, 0, ImageWidth(screen), ImageHeight(screen), 0, screen);

Posted on 2007-02-10 20:49:19

spaceseel

Now I've got my layout of my message box done. Now I'm attempting to do the text scrolling now. The method that I'm trying to use right now doesn't work. What I'm basically trying to do is to cut up the text and show it letter-by-letter. But when I try the method I'm using now, it just shows a jumble of letters popping up on the screen.


int scrollText(int x, int y, int fntName, string text)
{
int txtLength = len(text); //checks to see how many letters are being processed
int i,a;
for(i=0;i<=txtLength;i++)
{
PrintString(x+10,y,screen,fntName,mid(text,txtLength-txtLength+i,txtLength-txtLength+i+2));
wait(2);
}
}


Can you tell me what I'm doing wrong? And if there are any other methods, then do let me know. I'm kinda stuck right now.

Posted on 2007-02-12 19:36:14

Eldritch05

Use left(); instead.


PrintString(x+10,y,screen,fntName,left(text,i));


You should also probably start the for() loop at 1. Assuming wait(); functions like it should, this should make the text scroll, letter by letter, across the screen.

Posted on 2007-02-12 20:22:35 (last edited on 2007-02-12 20:24:03)

spaceseel

Thanks! That really helped a lot. But now it seems like after a while in the demo, I have to hold down the enter key just for it to switch message boxes. What I need to do is to make it so that it only scrolls the text once. I realized that when I placed the drawSystemBox() command that I created inside of the Render()...ShowPage() area, that the text kept repeating itself over and over again. I'm generally trying to get rid of the repetition and make it only scroll the text once. I'll try it on my own, but suggestions would be nice.

Posted on 2007-02-12 22:40:27

spaceseel

Never mind, I realized that when I took out the commands for doing the text scrolling out of the while loop, that I had no trouble with going to each box. When it was in the while loop, I realized that it kept rendering the text over and over again and that was the cause of the problem. Even though I have to wait for the text to scroll through (which I'm trying to fix to make the text just scroll through the entire way through when you press enter), I've worked it out easily.

Posted on 2007-02-12 22:59:17

spaceseel

Okay, I have the message box demo finished and posted in the downloads section. Let me know what you think.

Posted on 2007-02-13 18:49:08

mcgrue

It is totally a textbox demo!

Posted on 2007-02-15 20:30:42

spaceseel

Now I'm trying to implament the message box with a map loaded and a character and everything. I had to modify the code just to show the portrait and the box itself, but now I'm trying to get the text to scroll (or to show up at all). I had to place the system box command and the portrait draw command inside of the while(!b1) loop. When I place the scrollText command inside of the loop, the box doesn't seem to show up at all. I know that it's working, because I hear the sound that I use for scrolling every letter. It may be that the formatting of the scrollText command that may be wrong.

Posted on 2007-02-21 15:52:04

spaceseel

Okay...maybe what I should have asked is how to scroll text inside a while loop without it causing any troubles (or another way if possible). With the simple code that I have now, If I were to place the scrollText() command that I made into the while(!b1) loop, then I won't get any text to scroll (as for a matter of fact, not even the text box shows or the portrait for that matter). I'll look at the other demos for inspiration though. Any suggestions would greatly help.

Posted on 2007-02-22 18:50:57

Gayo

You need to keep track of the rate at which time is passing by monitoring timer or systemtime. That way the amount of text being displayed is a function of how much time has elapsed since the window opened.

Posted on 2007-02-22 19:21:32

zonker6666

heres how i would do 'text scrolling' -- not sure that its what you actually want tho...

-----------------------------------------------------------
| ^____^ | > adam attacks orc with axe |
| 0 0 | > orc parries the blow |
| == | > and retaliates! |
| | > hits adam for 28 points of |
-----------------------------------------------------------

portrait console like scrolling text


int textconsole=NewImage(320,FontHeight(myfont)*5);
int portrait=NewImage(1,1);

void SetPortrait(string img)
{
FreeImage(portrait);
portrait=LoadImage(img);
}

void ScrollText(string sometext)
{
// lets assume theres 5 lines of text
int height=ImageHeight(textconsole)/5;
int width=320;
GrabRegion(0,height,width,ImageHeight(textconsole),0,0,textconsole, textconsole);

RectFill(0,ImageHeight(textconsole)-height,width,Imageheight(textconsole), 0,textconsole);

PrintString(0,ImageHeight(textconsole)-height,textconsole,myfont,sometext);
}





Thats the basic idea ---- as usual most problems in life can be solved with GrabRegion()

Posted on 2007-03-02 06:25:08 (last edited on 2007-03-02 06:26:12)

spaceseel

This is the code that I'm using right now. It works for me. It works fast enough to not have to have the speed up when you press enter. I decided to use Rysen's WrapText() command, and I like it (credit goes to Zaratustra for the WrapText() code).


//for when we want the characters to say something
int textBox(string mbName, string mbTxt)
{
int done, s1;
int txtLength = len(mbTxt); //checks to see how many letters are being processed
int mbdone = 0; //resets the command, so it won't be confused the next time it's used.
EnableVariableWidth(MbNameFnt);
disableSubMenu();
int mbSound = LoadSound("data\sound\message.wav");
while(!b1 && mbdone=0)
{
for(s1=1;s1<=len(mbTxt);s1++)
{
Render();
drawSystemBox(10,330,630,470); //draws the box
PrintString(13,333,screen,MbNameFnt,ToUpper(mbName));
WrapText(13,350,550,470, left(mbTxt,s1));
PlaySound(mbSound, 80);
ShowPage();

if(s1==txtLength)
{
while(!b1) //waits for player input. After 'enter' is pressed, then the box exits out
{
Render();
drawSystemBox(10,330,630,470); //draws the box
PrintString(13,333,screen,MbNameFnt,ToUpper(mbName));
WrapText(13,350,550,470,mbTxt);
ShowPage();
mbdone=1;
}
EnterWait();
}
}
Unpress(1);
enableSubMenu();
}
}


Just to note: The reason that I drew the box a second time, is that for some reason, when the computer was waiting for player input so they could get out of the box, that the box just suddenly disappeared. I had to simply make it redraw the whole text and box while it waits for player input.

Posted on 2007-03-11 01:03:07


Displaying 1-20 of 20 total.
1
 
Newest messages

Ben McGraw's lovingly crafted this website from scratch for years.
It's a lot prettier this go around because of Jon Wofford.
Verge-rpg.com is a member of the lunarnet irc network, and would like to take this opportunity to remind you that regardless how babies taste, it is wrong to eat them.