> My progress on space wars has come a long way, in other words, it's
> getting close to being finished.
>
> I've run into a small snag. I was working on the ship to ship
> collision routine and when I got it close to being finished I tested it out
> and it slows MAME down to a crawl when it gets called. I'm checking every
> segment against every segment in the opposite ship. I'm checking 11 on ship
> 1 and 9 on ship 2 for a total of 99 checks.
I wrote an asteroids clone for the PC a few years back (Rocks486 if want to
search the net) and "invented" a couple collision detection schemes. For
the asteroids, I made a table of left and right edge positions for each
vertical coordinate in the rock. You take a point and check its Y value first.
If it's in range, you then check if the X value is within the span of the
rock on that line. This worked great for bullets hitting rocks and saucers.
For the player ship, I tested 5 points on the perimeter - these had to
be calculated, but 3 were coincident with verticies that needed to be
calculated anyway.
That worked great, but the saucers shoot at the player which rotates.
Since there was only 1 shot at a time that needed to be checked against
the players ship I first transformed it into "ship coordinates", reflected
it about the X axis (since in those coordinates the ship is reflected about
that axis) and tested against 2 lines. This gives really high precision but
at a cost.
A suggestion would be to make a collision table for each ship and then
rotate critical points on each ship into that coordinate system for a very
simple test. This should take less time that rotating the ship onto the
screen, since you can probably test fewer points for collision than you
need to draw it (especially for the Star Trek type ship).
Remember, don't bother with checking a bounding box first. If there is
enough CPU to do a full collision detect sometimes, then there is enough
CPU to do it every time :-) Unless you have a way to steal CPU cycles from
somewhere else when you need them.
And never apply more than one rotation to the original ship points even
durring collision detect.
Hope some of that helps,
-- ___ __ _ _ _ | \ / \ | | | || | phkahler@oakland.edu Engineer/Programmer | _/| || || |_| || |__ " What makes someone care so much? |_| |_||_| \___/ |____) for things another man can just ignore. " -S.H.Received on Mon Nov 29 14:09:11 1999
This archive was generated by hypermail 2.1.8 : Fri Aug 01 2003 - 00:32:31 EDT