Calculation for intercepting a moving target (leading shots)

I worked on the space game more tonight. In particular, I made the logic that guides an alien toward a citizen a bit more sophisticated by implementing moving target interception. Without this, if the alien just moves along the A to B path to the citizen, the alien ends up lagging behind the citizen because the citizen is in motion.

I described the derivation of this calculation in LaTeX a while back for a friend who was curious about it. I’ll attach the PDF here for anyone who’s interested.

Moving Target Interception Derivation PDF

Otherwise, the aliens now pick a target, descend to it, and freeze it in place to abduct it. I need to create an abduction animation to use. Maybe I’ll do that next time.

A soft interlude

At the start of the winter, I set a goal for myself to create a simple PC game I could play in the living room on my Steam Link with my son. Winter wears on, and I’ve been so focused on the motor and other hardware projects, I really haven’t done much with this goal.

Today I set aside the motor project (which is waiting on the 4mm parts from England) and worked a bunch on the game.

The game will be like Space Invaders or Galaga, but you shoot at the invading aliens from stationary positions, like Missile Command. The aliens’ goal is to descend and abduct citizens, who run in hapless panic back and forth across the bottom of the screen. Ideally you kill the aliens before they abduct anyone, but if someone does get picked up, you can safely rescue them by deploying a Sky Commando. Sky Commandos swoop in with wingsuits from the nearest side of the screen, and if you aim their arc correctly, they’ll grab onto the alien ship and attack it from within, destroying it and rescuing any abductees. Sky Commandos are a limited but reusable resource, which just means you can only have a finite number of them in play at a time.

The game is meant to be played with a gamepad since I intend to play it in the living room. I’ll release it for free if it shapes up into something worth releasing.

Today’s progress was implementing the alien AI that allows them to identify and move in on a potential abductee. Otherwise, I have the game engine in place (using the entity/component/system, or ECS, model) with an observer pattern to inform systems about entities they should care about or stop caring about. I’m implementing it all in C# using MonoGame. Currently the player can shoot at aliens with a rapid-fire weapon, and as I said, aliens will now pick a citizen to abduct and descend to get them.