@folmerkelly @LorenBednar <3 (Today)

@folmerkelly @LorenBednar I ESCAPED (Today)

@infinite_ammo Dads and bros. Fantasy football 4 lyfe! (Today)

@NoelFB @infinite_ammo Oh my god SO GOOD. :D (Today)

RT @NoelFB: . @Infinite_Ammo made a live color palette in the pixel editor last night. t.co/880iaU7fXI (Today)

@ADAMATOMIC Yeah I actually used it a month ago. I tweeted about a video of otters that I couldnt find again so I searched my archive for it (Today)

@ADAMATOMIC Hahah -- actually I think the "download your archive" option in your settings is pretty neat! (Today)

@ADAMATOMIC Just now realizing how weird it would be if my dad was tweeting about parenting when I was a kid and I could someday read it. (Today)

RT @mossmouth: I wrote a little thing about maturity, challenge, and video games: t.co/7nDijhY4uY *whispers* ...and art. (cough) (wh… (Today)

@Citizen_Daniel @ColinNorthway t.co/Y00JHQs8Lu (Today)

@henchmangoon Bummer! (Yesterday)

RT @Draknek: @theBanov Because when you see it, you one-der what the hell Microsoft is thinking. (Yesterday)

So is that free mobile thing from Unity only for the free version of Unity? Unity Pro still requires $1500 licenses? (Yesterday)

@Draknek hi@kpulv.com (Yesterday)

My favorite parts of Into Darkness are just the characters interacting and talking, but they're always interrupted by explosions... :I (Yesterday)

@Draknek @jmickle_ I post about Flashpunk on my blog but just end up linking people to your Github, so reviving the site might be cool. (Yesterday)

@Draknek @jmickle_ If someone else wants to do the forum stuff, I can help out with the rest of the site! (Yesterday)

@Clobbr @infinite_ammo Hey thanks! I wouldn't have any official booth space if I went this year though, I'd just be hanging out! (Yesterday)

@Draknek What is needed exactly? (Yesterday)

RT @unity3d: Breaking news! #UniteNordic David Helgason: Mobile game development with Unity is now free! More details soon! #Unity3d (Yesterday)

follow
search

2013 - 2 - 4 / 8:02 am / games

Dev Log: Some Bitmap Text

I guess I'll start calling these posts Dev Logs now? Yeah, that sounds good.

Image
The latest thing I've been chipping away at is handling bitmap text in my Flashpunk extended framework thing. There have been a couple of people that have posted Bitmap Font classes but they didn't do what I wanted, and I'm way better at coding my own thing from scratch vs. trying to modify someone else's code to do what I want.

Right now my bitmap text secret technology can do some cool stuff, like three different align modes (left, center, and right) which sounds pretty simple but it actually took me awhile to think of the proper solution for lining up text in a certain way. I also have some colored text as you can see in that awesome screenshot, and the way I do that is pretty cool (I think.) My code for coloring text ends up looking something like this:

//make da bitmap text
var bmpText:BitmapText = new BitmapText("This text will be #1GREEN!!#0 Yeah.", Global.bitmapFont);
//define the color "1" as green
bmpText.defineColor("1", 0x00FF00);


You can see a little bit how it works. I can define colors, which are assigned to certain characters (any Ascii character can be used) and then I can mark colors with a special character like '#'. Text after that character will then be drawn with a tint of that color. It's super easy to do colored words with this system, but it makes some other stuff pretty difficult.

One thing I still haven't figured out is how to escape the special character. Like if I wanted to actually display a '#' in my string, I don't have a way of doing that right now. I wanted to have '##' just escape out to a '#', and I was trying some fancy stuff with regular expressions for awhile but... yeah, things have not worked out yet. This is something I can probably just tackle later though.

Bitmap text comes in handy for a few reasons, and I think I'll make a more detailed blog post about that at some point down the road!

4 Comments
Avatar

2013 - 2 - 4 10:52 AM

Jake Albano

I assume you're looping through the string a character at a time at some point. Can't you just do something like this?

if (charAt(position) == "#")
{
if (charAt(position + 1) != "#"))
{
changeColor();
}
else
{
result += "#";
}
}

Obviously pseudocode, but that's how I generally handle escaping in situations like this.

Avatar

2013 - 2 - 4 11:59 AM

NounVerber

@jake
In your code the second # would still change the color. ;)

Avatar

2013 - 2 - 4 7:04 PM

Jake Albano

Well, yeah; obviously you would increment the position in the string so it would skip over the next '#'. I should have put that in there. :)

Avatar

2013 - 2 - 5 6:51 AM

Kyle

Yeah, I've tried a number of different ways but they all come with their own complications later. Like right now I'm having problems with typing out bitmap text character by character because of the color code escape stuff.

I was trying a simple technique of doing a string replace on "##" and replacing it with a random ascii character, and then when I hit that ascii character in the string I render the "#" instead. The problem then becomes that the internal length of the string is now one less than the given string because ## is translated into one character, and I use the string length to determine which character to type out next... maybe if I replace ## with two characters it will work... hm!

Avatar

Post your comment!

POST COMMENT

about

About

Hi there, my name is Kyle, and I'm a 27 year old kid with adult powers. I'm making video games and living the indie game developer life in Tempe, Arizona. Here you will find my thoughts, games, websites, doodles, and other stuff like that. I worked on Snapshot, Offspring Fling, and a whole bunch of other games. If you want to get a hold of me use the form on the bottom of the page, leave a comment, or just tweet at me. I try to post three times a week. Thanks for stoppin' by!

facebook

old sites

xerus kylepulver

contact

Your message has been sent! Thanks :)
SEND MESSAGE