Hello my lovable minions, today let’s talk about board games.
Well I’ve spent a lot of my downtime the last few days crawling through C++ in the Visual Studio debugger, and gathering crash data via adb from my tablet, all in the name of fixing threading bugs! A few core classes lightly stripped down and occasionally rewritten, a few things jiggled about and we have something that’s stable [on Windows].
I left several copies of this code running the other day as a test — none explicitly crashed, although there are persistent memory leak issues (aka, “gunking up”) over time which eventually lead to what is basically a freeze on the second thread, which does all the work. But in my testing all the sessions ran for at least half an hour at double speed (only a debug option right now, sorry), notching up an impressive health of over -5000. For reference, besides the threading related crashes everything else is basically the same as in the previous demo, so still lots of unfinished/unfixed/placeholder content and code.
Within the nme.geom package of HaXe NME you’ll find Matrices, Points, Vectors, Rectangles and… ColorTransform? Yes, it seems a slightly odd place to put it, but that’s where it is, and it can be useful in your project. No doubt, there are endless things you could do, but I wanted to talk briefly on how I’ve used it across my previous Pinball project and now, in Tower Defence.
Simply, sometimes you want the same object to appear multiple times in your project, but with subtle variations. Behavioral changes can be accomplished in code by subclassing, size variations by scaling, but what if you wanted it red in one instance and green in another? Including the same image twice with different colours seems redundant, even if the images in question are quite small, so what are your options? Well, a ColorTransform is an option if the image is a simple, single colour. In Pinball, I used this method to colorize the lights and lighting effects – the image files themselves were greyscaled, and were coloured in code before being displayed – and now in Tower Defence, I’m using it on some UI elements (the slider knob’s that change colour dependent on value).
Let’s step through how this works. First, of course, you have to create a graphic you want to use. Here’s the image of the slider knob in Tower Defence, as it came out of Photoshop…
This seems so obvious! It compiles to C so why can’t we throw our own stuff in there? Obviously you sacrifice the niceties of a higher level language like HaXe: Vague compiler errors and manual memory management abound, but it’s worth it sometimes.
For example: My first thought, since I’ve been implementing around it for some time, was to try and implement game saves on my TouchPad. I actually tried to use NME’s extension system to implement this a few weeks ago and got nowhere, so I wasn’t sure what to expect. I wanted to call into the webOS API to get a safe path using PDL_GetDataFilePath(), then write a string out to a file, and in a second function be able to read that string back.
Today I want to briefly talk about a cancelled project from around the time I finished University. Myself and a friend began building a game for this new platform called Windows Phone.