I have recently begun work on a new version of JetLag called, unimaginitively, JetLag 2011.
The most recent “full” version of JetLag was 2003, and was written in C++ and used SDL and Visual Studio .NET (the 2002 version, so with the rare 7.0 runtime).
I’ve had a number of other quick versions with blocks and sans lucky charms, but this time I wanted to really make a version with all of the bells and whistles, including full ASCII text mode graphics emulation, as well as the same sounds that I used in JetLag1999.
The first major issue that I had with the SilverLight version was the graphics.
SilverLight is meant to make really pretty things. Not emulate an ASCII screen from DOS.
I could not find a way to colorize an image, at least not without a pixel shader.
My needs are simple.
I simply need to take a white graphic and give it a hue in which to shade.
So, plan B – use 16 image, one of each color, and use a cropping technique to set the visible part.
This works, but it was very slow, and my frame rate was abyssmal.
Not to say that I needed a huge frame rate. I can make do with about 20fps. It’s JetLag, so it doesn’t smoothly scroll.
So I dug a little while longer.
I discovered that ImageBrushes render quickly.
Now the entire grid consists of layered rectangles given a Fill of various image brushes.
How many image brushes?
16 for the background rectangles.
4096 for the foreground rectangles. 256 characters each in 16 colors. Each one 16×16 pixels.
It takes quite a while to download the repository, as you might imagine.
Which is what I am doing now on another of my machines.
And I do cache them. The image brushes do not load the image until needed. It makes starting out a little bit slower(not noticeable on any of my machines, but I haven’t fired up my clunker yet).
The only question left to ask is “why”.
Why ASCII graphics? And in SilverLight, even.
(I also did them on the iPhone, as some may remember).
Really the technique that I found for using ImageBrushes would help with any game where a fixed grid of layered rectangles is needed.
Which is really almost all of my games.