@LowBitLovecraft     Morgopolis Studios                                                 Good Stuff! About

Sunday, March 27, 2011

Rocket Science

Dev Blog time.

Played Missile Master? Wondering why those stupid little 2D missiles never hit their targets? Allow me to enlighten you.

Fig. 1A
When the missile first fires there's no propulsion. It's sorta like you just lobbed it out the window. Authentic? Sorta. Responsive? Not at all.

Fig. 1B
The missiles have a little bit of horizontal inertia when you first launch them, so if you're moving to the right then the missile also moves a little to the right.

Fig. 1C
When a missile does take off it still has to reach it's maximum speed. Vertically, there isn't much intelligence behind a missile, but horizontally it's constantly hunting for prey.

This kind of poses a problem because the missile can only move so fast horizontally and if it has to change course then it's working against it's own inertia.

But that's not the real problem with how missiles in Missile Master operate.
The real problem is how they pick their prey.

Fig. 2A
Horizontally, missiles always go for the closer target. Once they have a target they start adjusting their horizontal speed to align themselves with the enemy.

Fig. 2B
But missiles can change their targets at any time, and they're always looking for an enemy that's closer vertically (which trumps horizontal). What this means is if enemy 1 flies in front of enemy 2 (the target) then the missile is going to go after enemy 1. But, when enemy 1 passes and enemy 2 returns to being the prime target the missile is so off-course it won't have a chance of hitting anything.

With this new project, Jet-Girl, I'm using the old code from Missile Master, but I'm redoing a ton of stuff.

Here's the advanced code that you don't have the pleasure of enjoying.

Fig. 3A
The purple cone represents potential targets for the missile. Whatever is closest within that purple cone (the cone is invisible in the game) becomes the target, which is highlighted in green (which is visible).

Fig. 3B
After you fire the missile the target becomes highlighted in yellow and the missile does not change targets.

Once the propulsion code gets redone the only way your missile is going to miss would be if the target moves really, really fast, or if something jumps in the way and sets the missile off early.

Missiles now point in the direction they're moving.
I had no idea how important this feature was until I put it in.

No comments:

Post a Comment