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'm implementing the following formula for each segment check (re-written in
assembly, of course, for a total of about 300 lines of code)
x1,y1 - shot initial position
x2,y2 - shot new position
x3,y3 - last point from ship used to check collision
x4,y4 - new point from ship used to check collision
a1=y2-y1
b1=x1-x2
c1=x2*y1-x1*y2
r1=a1*x3+b1*y3+c1
r2=a1*x4+b1*y4+c1
if r1 & r2 !=0 & have same sign, they don't intersect
a2=y4-y3
b2=x3-x4
c2=x4*y3-x3*y4
r1=a2*x1+b2*y1+c2
r2=a2*x2+b2*y2+c2
if r1 & r2 have same sign, they don't intersect
This works find for shot collision detection (I'm using the old shot
position and the new shot position for the line endpoints), but it's way too
slow for ship to ship.
What I'm wondering is, does anybody have a simpler way to check for the
intersection of 2 lines?
-jeff
Received on Thu Nov 25 12:21:07 1999
This archive was generated by hypermail 2.1.8 : Fri Aug 01 2003 - 00:32:29 EDT