GBA Fonts...

Started by
3 comments, last by RegularKid 21 years, 4 months ago
What is the best way (or most commonly used) to display text on the gba? I was thinking of just using up 36 sprites (26 for alphabet and 10 for numbers) and then parsing strings to index an array that points to the correct sprite character. Any suggestions?
Advertisement
Sprites will work fine for smaller strings like "get ready", "game over" and such, because you can make them move in interesting ways.

The most common used technique, I would assume, is drawing the font as tiles and using one of the tile layers to put text on screen.



A 2D Developer''s Board
Personally, I use sprites. I don''t like the OAM it takes up, but I find it gives you a lot more freedom with things. You can scale words for bold effects, make the letters jitter, etc. If you''ve played Golden Sun you can see what I mean, as they use a lot of effects like that. The map layer works good too, and I may turn to that eventually, but so far the sprites are still my favorite. One thing, though. I should think you''d want at least 62 "sprites," more likely somewhere around 70. It depends on what kind of game you''re making of course, but for an RPG its pretty important to have 26 lower case, 26 capitolized, 10 numbers, and a handful of punctuation marks. In that case, what I do is initialize as many sprites as I can have onscreen at once, and whenever I call text, I simply move the sprites onscreen, and fill each of them with the appropriate image data. That way you can use each character more than once (as opposed to using one sprite for each letter) and you also save sprites. If you can only have 50 letters onscreen, it''s easier to store 50 sprites than it is to store 70 for letters that aren''t even used.

-Arek the Absolute
-Arek the Absolute"The full quartet is pirates, ninjas, zombies, and robots. Create a game which involves all four, and you risk being blinded by the sheer level of coolness involved." - Superpig
Arek,

I like your idea of using sprites for letters. I also like the idea of the map layer, although I do not know anything about that yet.

When you are displaying a dialog, like a cutscene from Ninja Gaiden or Final Fantasy (where the player presses a button to show the next set of text lines), how would you go about setting that up? Closest I can come up with is to "write" two lines of text onto the screen and then wait for the user to press a button. (Actually doing that is a mystery to me. )

Then again, with a map layer, if you store a background map with multiple letters and punctuation marks, it''s true that you may never need to use them all, but would you be able to quickly call up whatever letter you needed simply by referencing an index in an array.

Thoughts?
-slippers2k

Attack life''s problems like a Subaru... with all four wheels
Attack life's problems like a Subaru... with all four wheels
quote:Original post by slippers2k
When you are displaying a dialog, like a cutscene from Ninja Gaiden or Final Fantasy (where the player presses a button to show the next set of text lines), how would you go about setting that up? Closest I can come up with is to "write" two lines of text onto the screen and then wait for the user to press a button. (Actually doing that is a mystery to me. )


Well, it really depends on how you intend things to work. In the case of Ninja Gaiden, it's all a pre-planned out scene that distinctly breaks the mode of gameplay, so things are a lot easier. All you'd need to do is move the sprites that contain the image data onto the appropriate place for the first line of code.
When the user hits a button, you change the data in all the sprites to match the new letters. In a ridiculously over-simplified code example:


    #include <somemysticallibrary.h>// this will hold all the lines of textconst char *text[] = {"This is the first line of text",                      "This is the second line of text",                      "This is the third line of text"};int main(){          // declare some variable to track          // what line of text we're on          int line = 0;          // game loop          while (1){                // this function moves sprites into place                // and fills them with the appropriate letter                // data, matching the string we give it                PrintText(text[line]);                // if the player hits a button, increment line                if (A_BUTTON_DOWN()){                    line++;                }          }}    


This code is by no means perfect, but it hopefully demonstrates the point.

If you wanted to do it more like in Final Fantasy, it could get a bit more complicated, but I'll let you see if you can figure that out. This would work for Ninja Gaiden style cutscenes, provided these functions and stuff actually existed.

quote:
Then again, with a map layer, if you store a background map with multiple letters and punctuation marks, it's true that you may never need to use them all, but would you be able to quickly call up whatever letter you needed simply by referencing an index in an array.


I'm not sure I take your meaning. If you have a map layer, most of those issues are negated. You simply fill the tile data with the alphabet image, and fill the map layer you're using with data corresponding to the letters you need. In all, I'd say it works a lot easier than sprites. The downside is you lose the ability to scale, rotate, or otherwise change individual letters, like the effects I described in Golden Sun. Perhaps more importantly, though, is it takes up an entire map layer, which will make Mode 2 all but useless, and limits the possibilities of most other modes as well.

I don't know. I doubt I answered that question, but I don't quite get what you're asking. Sorry.

-Arek the Absolute

[EDIT] Fixed quotes

[edited by - Arek the Absolute on December 6, 2002 4:13:29 PM]
-Arek the Absolute"The full quartet is pirates, ninjas, zombies, and robots. Create a game which involves all four, and you risk being blinded by the sheer level of coolness involved." - Superpig

This topic is closed to new replies.

Advertisement