Predicting a path through moving objects

Hello,

For fun I’ve reproduced the classic game Asteroids. It’s going well so far. I am to the point where a flying saucer can relatively accurately hit the ship if it’s traveling on a constant heading.

Now I need to figure out how to introduce the saucer. In the real game, the small asteroid is quite adept at moving through the field of asteroids, which is presumably because the program checks each asteroid’s trajectory and calculates a path through it. Kind of like the Millenium Falcon in Episode IV.

Does anyone have any ideas for how to calculate a “safe path” through a set of moving asteroids? What we know about each asteroid is its speed and direction. I’m guessing that a function fired repeatedly by an ENTER_FRAME handler, to update that path (the saucer can change direction) would have to be quite economical in order to save CPU.

Thank you,
Tim

You’re on the right track. Simulate time and figure out if you’ll ever have a hittest with an object you’re concerned about. If that’s taking too much CPU time, limit the scope of either 1) how far in time you’re looking ahead 2) how many objects you’re looking at, or 3) don’t do everything each frame. There’s not necessarily a problem with downsampling from 60 to 30 or 15 FPS in predicting movement, since those time slices are pretty small compared to how slow the motion is going to have to be for people to be sitting there watching the game.

In some old games, they put two points a distance ahead of the object, one on the right and one on the left.

If the right ‘sniffer’ was hit the object turned left and if the left ‘sniffer’ was hit, the object turned right. I’m pretty sure this was referred to as ‘AI’