Jump to content
  • Advertisement
Sign in to follow this  
-justin-

Best way to do a Text Box [SOLVED, for now ^^]

This topic is 4709 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey everyone I want to do a text box like the ones they have in RPG's like a speech box or something. Since that will be pretty useful in my games. And I was wondering how to do it in the best manner. My idea was something like this, you declare a string. And anytime you get to a /n that means wait for the user to go to the next "box"; a /et means the end of the conversation... I personally am using directx so I would use the built in font command.. so like an example would be like this: "I am the warrior called Kazar, there isn't a single person in BLAH BLAH that doesn't know my name.../nFEAR ME!!!!/et" so we would go through the characters with like a loop while there wasn't a "/et", etc let me know what everyone thinks of this idea and/or more efficient ideas Thanks :) [Edited by - -justin- on November 3, 2005 5:02:42 PM]

Share this post


Link to post
Share on other sites
Advertisement
Are you asking how to implement the textbox in Direct3D? If not, then i'm not really sure what your asking.

Take care,

ace

Share this post


Link to post
Share on other sites
ok... in RPGs you know how you go talk to people and a text-box pops up?

I want to have some textboxes in my games. For instance in my side-scroller, to tell the story, I want to have a textbox...

does that make more sense????

Share this post


Link to post
Share on other sites
Your going to have to look into:

- pre-transformed vertices using RHW component in vertex dclaration.
- billboarding.
- D3DXFont interface for font handling.

Hope that helps,

ace

Share this post


Link to post
Share on other sites
yes yes, i know how to get it on the screen

i'm talking about the actual implimentation, as with the text and such (not the graphic end) but how does my implimentation of the text loook... how does everyone else do it... (sorry i guess i'm being too vague here)


ok, see

i'll initialize my string


// assume that #include <string> was called

char text[] = "Hello traveler.[n]If you are in need of items please go to the
North there you will find the wandering salesman.[n]If you need lodging,
please go to the East you will find the best inn in the Western half of the world";

int len = strlen(text);

// added returns so that it wouldn't screw the forums up






then something like:


for(int i = 0; i <= len; i++)
{
if(text == '[' && text[i+1] == 'n' && text[i+2] == ']')
{
// then we make a new buffer for our D3DXFONT
// we copy the current text into the buffer
// call our direct font function

// clear buffer
delete buffer[];
// reintialize
char buffer[];
i += 3; // go to the next "box"
}
}






i mean, i'm thinking this isn't the best way... so could someone share with me what they do?

[Edited by - -justin- on November 3, 2005 4:25:12 PM]

Share this post


Link to post
Share on other sites
This sort of data is like an outline.

Player starts talking with the Old Man of the Mountain and there's 4 things he can say. Each of these 4 things has its canned response and then after that, there's some number of things the player can say as the conversation continues. So set it up like that. The trick is that some nodes in this tree lead to other places in the tree. So the player can say "That's enough about all that, lets talk about something else" which is, in effect, returning to the root node. Or wherever.

If you can lay your hands on a copy of Neverwinter Nights, they have a real nice dialog editor that works in just this manner.

Share this post


Link to post
Share on other sites
ohhhhh trees? nodes?

hmm, guess ill have to look into these, heh; been avoiding them ^^

thanks, that is good for choices... but i'm still not sure of the best way to just actual text (take a blob of text and output it on the screen in chunks)

Share this post


Link to post
Share on other sites
Your idea might work, though it's not very far in flexibility .. ie, what about branching conversations? Text that may need to displayed in different colors and so on?

What I would do is create a 'conversation tree' with each node containing speech text. The root node would be the very first thing the guy says. If the node has a child (or more than one child) you know the conversation doesn't end there, and he can still say additional things, it's just up to you to figure which path to take.

An additional benefit to having a tree like this is you can easily track where in the conversation you currently are, without any additional string parsing.

It also opens itself up for a data-driven architecture, since you can save out your conversation tree in xml format for easy editing (as an example).

Edit : Just noticed my reply was late ;) I pretty much second dalep's response. Using a tree will effectively split your text blurbs into chunks, exactly what you want. You can just mark some nodes as 'choices' and others as 'wait for user continue' or something.

Share this post


Link to post
Share on other sites
whew, sounds complex, heh, i'll probably get into nodes/trees next semester in programming II?

but now you've given me something to look at over the weekend!

EDIT: THANKS EVERYONE :)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!