Since I last posted I've mainly been doing some improvements to the comic overlays and some general refactoring/improvements, as well as some changes to the game control interface (I may blog about the latter soon). Yesterday and today, though, I decided to add guided missiles to the array of weapons in Juggernaut.
The standard projectiles types have a very simple dynamics model, and simply move in a straight line until they collide with the main collision stencil (or their lifetime expires). This type of collision detection is performed on the GPU, and therefore is highly efficient, which is why it is a good choice when there may be thousands of collisions to determine. The downside to using GPU-based collision detection is the necessity of a GPU-stall before you can actual get the information back to the CPU. The stall is necessary as the GPU needs to finish its current queue of commands up to and including the collision detection operations before the results you want are available. At the moment on my GTX260 this stall is only at around 3ms, when 16ms is generally available per frame (assuming 60Hz), so this is not much of a problem. To avoid just losing this time, the GPU-based collision detection operations are queued, then the main CPU-based updates are performed before the stall is forced.
Anyway, the missiles are effectively treated as standard projectiles, but with more complex dynamics that allow them to select a target and then accelerate towards it. They will also spawn different (and larger) explosion types to the majority of projectiles and cause splash damage to other enemies. The larger explosions aren't properly implemented at the moment, though: that's today's task!
Here's a screenshot of the initial missile implementation, along with a nice blue vapour trail to add some visual variety.
No comments:
Post a Comment