Tag Info

Hot answers tagged

14

Dialogue could be provided in any form/structure you wish it depends on how you parse the information that makes the difference. I will provide you with a basic XML syntax to get you started without understanding your games structure or language I afraid i cant provide an implementation. <?xml version="1.0" encoding="UTF-8"?> <npcs> ...


8

You need to use SpriteFont.MeasureString. Vector2 textSize = mySpriteFont.MeasureString("Hello World"); Vector2 center = textSize / 2; The x component of textSize represents the width of the measured string while the y component represents the height.


8

I won't write the code for you, but I can put forth a conceptual path forward. Assuming your text is displayed in a string, it is possible to iterate through the character array that makes up that string. The goal here is to print each character individually (or however many at a time you want) separated by a delta time. When you think about it, this isn't ...


7

There are a lot of ways - depending on what you want... Like everywhere else, there isn't something like "the best solution". Which plattform is your target? Which language are you using? What is about text resizing/rotation - is it necessary? Do you need to be able to render TrueTypeFonts? Whats about Multilanguage/Unicode? How do you want to store your ...


7

ID3DXFont can be used to render 2D text, and D3DXCreateText can be used to generate a 3D text mesh you could render as well. In general I would think the 2D approach is preferable, unless you want the text to do something odd like spin in 3D space. To find the appropriate place to start rendering the text (for the 2D case), you'll want to use the ...


6

You need to modify your model so that the UV (texture) coordinates place the texture at the correct location. It's possible that setting the texture address mode to clamp may (sort-of) solve your issue. But this also depends on your model having the correct UV coordinates to make it work. GraphicsDevice.SamplerStates[0] = SamplerState.LinearClamp; (The ...


5

If you want to use bitmap fonts, you can't go far wrong with the Angelcode Bitmap Font Generator: http://www.angelcode.com/products/bmfont/ It converts a truetype font to one or more textures (with nicely packed glyphs), and outputs a little file containing the UVs and spacings (I find that the XML output is particularly easy to work with, and the quality ...


5

The Problem is that you draw your text on the screen and then blit the doublebuffer over that. Simply change the first argument to textprintf_centre_ex from screen to buffer and it works like a charm.


4

I think, without a library, this would require quite a few steps, but it is certainly possibly. First convert the letter to a polygon (look at the bitmap to polygon algorithms) and then that polygon to a set of triangles using a technique that supports holes in the polygon, see this wiki page. You now have a flat model built out of triangles. Now draw the ...


4

Although XML is more predictable, kinda have a defined structure and all that. I would go with scripts. Rolling your own language(if you have the time, but usually this is not the best choice), or even implementing one. There are LOTS of script languages out there, they're all nice, some examples: Squirrel, Lua, Angel Script, Python, and many many many ...


4

You should generally prefer structured data (XML) over scripts at every opportunity. The biggest reason for this is tool support. You can make a dialog editor for a structured format, which supports internationalization, dialog branching, testing a debugging of dialog trees, deadend and infinite loop detection in trees, etc. For a script, the only thing ...


4

If you want to do it the old-fashioned way, then yes, you can use it in a grid. But if you want to use any kind of variable or half-width characters, like writing 5 instead of 5, then you'll need to get off the grid. The characters are all the same width anyway so if you're not using any non-Asian characters then it should align by itself. I don't think ...


4

The way I handled this in my simple textbox UI element was to use a scissor rectangle (as Nicolas Bolas said while I was writing this :P). Here's the basic idea: First off, create a RasterizerState field in whatever class does the drawing of the text like so: RasterizerState _rasterizerState = new RasterizerState() { ScissorTestEnable = true }; ...


4

In the games I've worked on, we restricted the subset of characters used for Chinese, Japanese, and Korean (together referred to as CJK) to only those required to display the text in the game. In other words, we didn't attempt to cram in every possible character; we just took the database of CJK text from our localization teams, did a pass over it to find ...


3

If you want to clip things to a certain region, you use the scissor box. It's a property of the GraphicsDevice: GraphicsDevice.ScissorTestEnable and either RenderState.ScissorRectangle pre-XNA 4.0 or RasterizerState.ScissorTestEnable in XNA 4.0. You don't need to measure text for it; just set the scissor box to the area you want to clip to. You can draw all ...


3

You will have to manually get the size of the screen and scale down the requested text size.


3

There is also a research article from Microsoft Research by Loop and Blinn, on rendering resolution independent curves using shaders. It suggests using the presented technique to render TrueType text in a resolution independent fashion.


3

You can use D3DXCreateText to create a text "mesh", which you can then render however you like.


3

One thing I have seen often is highlighting key words like places, a macguffin to collect and key characters to talk to next. this allows a player who is just skimming to stop and reread the context consider having a fortuneteller character who gives more direct hints, just someone who will be always available to talk to maybe in the home town maybe ...


3

Given SpriteFont font; Do this: Vector2 size = font.MeasureString("Your String Here");


2

A popular framework is Crazy Eddie's GUI. But whilst that is appealing, its not unusual to roll your own (and perhaps regret it as the scope increases later ;)) Its normal to have your glyphs on bitmaps and then draw the bitmaps using OpenGL. Sometimes you show transient text that might only appear for a handful of frames. Just using GL_QUADS+glVertex ...


2

In your code flow, you are drawing the "Pause" text immediately when the player presses p. Later on in the same frame, you draw the other sprites. Pygame blit operations always draw on top of what has already been drawn. If you want the pause text to appear above everything else in the game environment, you'll have to move the code that blits it to a ...


2

In my engine, I use a dynamic vertex buffer for batching up text data (each character == 1 vertex) and do point-to-quad expansion in geometry shader. As far as I know, glVertex*, glNormal*, glTexCoord* are considered obsolete (like display lists) and are not recommended to use. This gives a comprehensive overview of various OpenGL-based text rendering ...


1

I'm not sure if there is a game-specific translation framework but I've used gettext system for handling translations in WordPress. Here's the WP page describing their translation process along with a list of tools. The gist is that you create a template file that you in turn use to create translations. The final step is producing a binary, machine optimized ...


1

The easiest way is to use a bitmap font. You create a table that maps each ASCII (or UTF) character code to a region of a texture that contains all the characters you want to use. To draw a string, you create a vertex buffer with positions and textures, adding on a quad for each character, where the quad's size and UV coordinates are taken from the table. ...


1

No. You can't do that with AngleCode's Bitmap Font Generator. You could take the resulting image and location information and run it through a separate sprite sheet editor to pull the images out. Then resize them to the widest character and put them back. Though, you're best bet is to find an alternative font generator. This isn't really the place to ask ...


1

you can convert the spritefont into a Texture2D (RenderTarget inherits from Texture2d i think) as described in this article http://nullcandy.com/particle-text-in-xna-and-javascript/ Vector2 size = font.MeasureString(text) + new Vector2(0.5f); int width = (int)size.X; int height = (int)size.Y; RenderTarget2D target = new RenderTarget2D(device, width, ...


1

I can't give you a short example using LWJGL alone, but what I can do is give you an way to solve your problem. As I understand, you want to load one font at rendering time, and display it right away with multiple colours. My suggestion is to use Bitmap Fonts for this. Just use a tool (Example) to generate the bitmap font texture file and the textual file ...


1

While XML would make a great way to store your dialogue text, the most important aspect is the ease with which you can read it in, as well as how easy it is to write. Keeping all your dialogue in one file (or multiple files in a single folder) will make it easier to add translations later. All you'd have to do to choose between them is decide which file (or ...



Only top voted, non community-wiki answers of a minimum length are eligible