RE: Space Wars

From: Brian Deuel <bdeuel_at_pathwaynet.com>
Date: Tue Feb 01 2000 - 22:28:20 EST

Anyone know what ever became of this project? Jeff?

-----Original Message-----
From: owner-vectorlist@lists.cc.utexas.edu
[mailto:owner-vectorlist@lists.cc.utexas.edu]On Behalf Of jeff hendrix
Sent: Thursday, November 25, 1999 1:20 PM
To: vectorlist@lists.cc.utexas.edu
Subject: Space Wars

        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

---------------------------------------------------------------------------
** To UNSUBSCRIBE from vectorlist, send a message with "UNSUBSCRIBE" in the
** message body to vectorlist-request@synthcom.com. Please direct other
** questions, comments, or problems to neil@synthcom.com.
Received on Tue Feb 1 22:42:33 2000

This archive was generated by hypermail 2.1.8 : Fri Aug 01 2003 - 00:30:57 EDT