RJ 9-bit

This is my tiny tiny pixel font. Every character is made from a 3x3 grid and it supports the basic latin character set (but the punctuation is a bit of a mess to be honest).

Continue reading...

Damped Springs

I've worked on third-person camera systems for numerous games and I often need a method for smoothing camera motion as the player moves through the world. The player’s motion may create sharp, discontinuous changes in direction, speed or even position. The camera, however, should:

  1. Avoid discontinuities in motion. Accelerate and decelerate as needed rather than snap to a new velocity.
  2. Never let the player outrun the camera. The farther away he gets, the faster the camera needs to move.
  3. Move exactly the same with respect to time regardless of frame rate.

To solve this problem, I often simulate the camera with a set of damped springs.

Continue reading...

How to use ASSetPropFlags in ActionScript 2.0

There are multiple undocumented functions in ActionScript 2.0 of which one is ASSetPropFlags. I needed to use this function on a project recently and quickly found out that most of the unofficial documentation is either incorrect or overly brief. What I'm going to do here is describe how the function works and then show a program that will test and confirm some of the more complex functionality. 

Continue reading...

Parsing Colors in a TGA File

Having just written a parser for TGA image files, I had the pleasure of learning that the storage method for color data was not clearly defined by the documentation and that the few pieces of example code I could find all contained bugs. In an attempt to rectify the issue, let's walk through the different ways color data can be packed into a TGA file and how to read it back. 

RGB Color Space Conversion

I've been on a bit of a color science kick lately and transferring from one color space to another becomes a common operation when you want to properly play with digital color values. Normally we just think of digital colors as RGB values, but there are many ways to numerically describe a color. Just opening PhotoShop's color picker lets you choose colors as HSV, Lab, or CMYK values in addition to the standard RGB. If you're a bit more adept with PhotoShop, you've may have even ventured into the Color Settings which has even more options including which version of RGB that your image will use. It is this concept of multiple RGB spaces that I'm going to focus on. 

Depending on how you ended up here, it might even be a surprise that there are multiple types of RGB, so I'll do my best to present some background on that and introduce a color space called XYZ. Then we can walk through the math for converting between all these RGB variants and discuss why you would even consider doing so. Finally, I'll present some example code for implementing the color space conversion.

Continue reading...