Saturday, 10 December 2011


This is a simple tip about how to do buttons in Flash. You can make them however you like, using code (as I usually do) or in Flash CS's editor. But always make them dynamic.

Friday, 9 December 2011

My 2D Vector class - and why I no longer use it

For Bug Tunnel Defense I created a 2D vector class. The nearest thing built in to Flash is the Vector3D class, but that with four elements is twice as big as I needed, and also uses Number rather than int as I wanted. I wanted something to store 2D grid positions, for game logic, so I created my own class. Then barely used it.

Thursday, 8 December 2011

My TextField class

This is a class I added to replace all instances of TextField in Bug Tunnel Defense, to eliminate half a dozen lines of near identical code after each call of new TextField();

The constructor for TextField for some reason takes no parameters, even though you pretty much have to set some properties for an instance you create in code. I added  parameters for the defaultTextFormat, x and y which I was always setting, as well as an optional Boolean to make it right aligned. For those text items that were fairly dynamic and so could change alignment I also added functions to set the alignment and position at the same time.

Wednesday, 7 December 2011

Bug Tunnel Defense: Names

(originally posted 25 May 2011)

The game had at least four names during development, that roughly trace the history of its design.

Monday, 5 December 2011


Ballistics concerns projectiles such as darts, balls and bullets that move through the air unpowered, after being fired or launched from a gun or by hand. There are many ways to do this but it's common to make two simplifying assumptions.

First it's normal to assume that air resistance doesn't matter, because the projectile is heavy, it is aerodynamic, or the time of flight is so short that air resistance makes no difference. This may be unrealistic but it is good enough for game simulations, and makes the mathematics solvable.

The other assumption is that the target is no higher or lower than the launcher, so they are at the same height. This is more a constraint than a simplifying assumption but it's one that works well for many game types, where e.g. all combatants fight on the same level. It greatly simplifies the mathematics.