If you were pondering what I’m pondering (other than wondering if, provided the shrimp was giant enough, you could ride it) then target locking has been on your mind. Well, maybe if you were in the process of creating a shooter wherein no fewer (but not exactly more) than 2 different enemies shot at you the same way.

You see, on a basic level both the flying fortresses and the ground turrets use the same kind of shooting. First, they’re pretty harmless and mosey nice along the screen. They don’t even move terribly quickly. But if you get too close they’ll lock right on like a, um, lock and shoot bullets at you. Until something else has the bright idea to get in range of their furious bullet shaped wrath.

This behaviour is supposed to encourage a long range solution when you’re playing single player. Both enemies can take a bunch of hits before exploding into a joyous ball of fire and also smoke, so lining up quality shots from as far as you can is a good idea. In multiplayer those same enemies’ tendency to throw hate at a particular player should allow the other player’s to draw it their way through clever flying and a high risk kind of constitution.

Which gets us to the two competing ideas for this. On the one hand I can use a somewhat basic shooting mechanic that will shoot along the 8 axes (the plural of “axis” although pronounced “Ackszeese”). This has the great ability to simplify the shooting for the entire game since then every kind of bullet will travel in these lines. A well versed player will be able to understand the firing “lanes” and use them to some effect. Which could be great if I wanted to make a game based on thinking. Paper Zeppelin is supposed to be a little hectic.

On the other hand I could use an equation to calculate out the vector of the bullet. This would add the kind of chaos that I kind of like, although actually takes more thinking from me. I believe I’ll try that one out, just to see if I can make it work correctly. If I hate it, I can always do the easier thing instead.

-Wows, “use an equation to calculate out the vector” sounds a little complicated, so I’ll explain what “vector” means. In this case, the “vector” is the distance traveled. In 2D space (although you can also use a vector in 3D space) it is the difference in the X and Y position since the last time we checked. So if the movement vector is 2,1, it means that whatever it is has moved 2 units of whatever along the X axis and 1 unit of whatsit along the Y.

In 3D is where we get weird stuff. So if you’ve ever wondered what the hells the people in Star Trek are talking about when they say that something is at 81,17,26, well now you sort of know.

Oddly, I’ve worked out the maths involved for calculating these things in advance. It works like this. Say we have 2 objects, and one of those objects is shooting at the other. We know that object 3 is 2 units to the left of object 2 and 4 whatsit units above them. Using some quick math that looks like this (a^2 + b^2 = c^2) to figure out that the long side, the distance is between the 2 objects is 5.

Knowing the distance we also know how fast the bullets are supposed to go. Let’s say that they go 2 whatevers every second. 5 / 2 gives us 2-1/2, so the bullets should arrive at where they are supposed to go in 2-1/2 seconds. Then, we divide the x and y distances (3 and 4 remember) by how many seconds (2-1/2) to see how far along the x and y axes the bullet is supposed to go. So in this case it’s (4 / 2-1/2) and (3 / 2-1/2) or 1.6 and 1.2.

After all of that math, the vector for those bullets will be 1.6,1.2. Thankfully the computer is really good at math. Really good.

So what does that have to do with Paper Zeppelin? Well, if a Turret is going to shoot at a player it knows where the player is and it also knows where it is and it should know how fast bullets are supposed to go. I can plug all of that information to create a bullet that goes the correct speed in any damn direction I can think of, and I can think of a lot of damn directions.

-Slightly off topic, yes, that was a short um, crash course in Trigonometry. Oddly, I never thought much of it when I learned it originally, and honestly forgotten most of it. If you’ve ever thought that you won’t need this, you’re probably right. Forgetting it, then recreating the equations from scratch, it much harder than remembering in the first place though. So really, it’s not that you’ll never need it, it’s that once you know it you have to discover something to do with it. I do indie games, and I need it constantly.

So, the more you know, I guess. (cue jingle)