Question boxes: tiles made in running time.

8 05 2010

Maybe you know, maybe you don’t (probably the latter), the texts in Tanuki Tail, so far, are sprites. (for example, in scripts). These sprites are created and deleted dynamically, and every time a character is created, the 16 pallete is applied, id est, the sprite is built in the time it’s created, from a base sprite, and then added 16*palnumber to each nonzero byte, to get a different “row” on the 256 color palette. These are the most flexible texts and they’re used in scripts. They work good on it because there’s a delay between each character creation.

The problem with these is that they’re slow. Without delay, you’d be creating about 60 sprites in a row, which doesn’t sound like a good idea. That’s why, in the inventory, I use a variation of those fonts: a fixed number of characters are created and put away from screen (this also implied changing a bit my sprite system, because otherwise that would mean to delete the sprite), with the palette applied beforehand (the sprite source is copied and modified before creating sprites with it). Since the Font class manages two arrays of characters, this second approach applies two palettes, one for each row. I use these to show the item name and description, so the item name goes in one color and the description in another. Classy. Anyway, these fonts aren’t as flexible as the first ones. They are to be used when I want to print a single text that won’t change color.

But then I wanted to show pop up boxes, to ask the player to confirm the use of an item, or to ask how many items are to be tossed. And since the inventory GUI is quite complete, I have about 110 sprites on the bottom screen. (I had about 120, but modified the function that shows how many items of some kind you have to build the sprite out of three digit, instead of creating three sprites of one digit each). So if I wanted to make boxes with text, I had these options:
-Make a background, and then a text background to show the ugly tiled fonts. yuk.
-Make a background, and then an 8 bit background to put text on it. Seems expensive
-Make it all in a single background BECAUSE THAT’S WHAT A TRUE MAN DOES

So I got the third option because of my astonishing manliness. From the same font sprite file and width data as before (in fact, the first step is creating a common [1st approach] Font class object), and a 10 tiles tileset (blank, inside, top left corner, top side, top right corner, left side, right side, bottom left corner, bottom side, bottom right corner), I create a tileset containing my desired text. I print each string over copies of the “inside” tile, and attach them to the original tileset (a copy of it), and then build the tilemap depending on the amount of text and its length. Then there’s only the need of one sprite, to be used as the selector, and do the selection logic (also stylus support). In the case of numeric questions, the number of digits is a parameter, and sprites for them are created, through a quick font [2nd approach]. The maximum possible width of the numbers is taken into account for the size, and so is the width of the current number shown, to center it. Here’s the result (with a placeholder tileset, that is):

The only catch is that the tileset must use the font palette, but this isn’t an inconvenient, since the palette is quite complete in colors, and there’s a lot of unused color slots (for example, the first color in each 16 color row, because that’s supposed to mean transparent to fonts.

The current implementation allows up to 9 options, with the only restrain of fitting into screen. The box is centered and since it’s built in runtime, it can be of any size.

Also

There will be a new release soon, probably, or probably not, so you can play with the inventory GUI, interact with stuff on the map, and some stupid things like jumping like a frog. EXCITING ISN’T IT?


Actions

Informations

Leave a comment

You can use these tags : <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Spam Protection by WP-SpamFree