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

Started by
7 comments, last by -justin- 18 years, 5 months ago
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]
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
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????
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
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 calledchar text[] = "Hello traveler.[n]If you are in need of items please go to theNorth 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]
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.
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)
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.
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 :)

This topic is closed to new replies.

Advertisement