Re: RE: Space Wars

From: Paul Kahler <phkahler_at_Oakland.edu>
Date: Thu Feb 03 2000 - 13:03:06 EST

> The problem is when both ships get within each others bounding boxes. Then I

Got it. Consider this (and shoot it down if it's not good).

Make a low resolution "bitmap" of each ship. Then check 10-20 points
of the opposing ship to see if they collide with this bitmap. Now you
may think this requires transforming all those points into bitmap
coordinates, but think again. The center of rotation can just be
translated into bitmap coordinates. Then neighboring points can be
gotten to by adding the basis vectors of the rotation matrix - if
you stick to an integer grid, you'll just add/subtract sin,cos values
to move to new points (kind of like the Apple II shape tables). You
could hard code the add/subtract combinations once you decide what
shape to use, or stick to a table.

For example, to check a rectangular ship you may start at a point and
then make the following moves:
UP,UP,RIGHT,DOWM,DOWN,LEFT

where the vectors are defined:
UP = (-sin(a),cos(a))
RIGHT = (cos(a),sin(a))
DOWN = (sin(a),-cos(a))
LEFT = (-cos(a),-sin(a))

use 8 bit fixed point values and then cut them down to 4 bits and combine
to form a 8 bit index into the bitmap for the other ship. The bitmap can
tell you what part you hit. The hardest part on a 6502 will be combining
the upper 4 bits of the 4.4 fixed point numbers - Hmmm, you'll need to
keep to a 8x8 pixel bitmap to avoid wrap-around collisions within the
bitmap.

This could may work really good if you use a "compiled shape table" to
check points in the opponents bitmap :-) You could OR together all the
pixels you step on in the bitmap and use different bits to indicate what
part of the ship each pixel is. That way the scanning would not require
any conditionals, and the result would be a byte that tells you what
you hit.

Gosh I'm thinking with clarity today :-) Lemme know if I've conveyed this
idea well enough.

BTW, I've never heard of this method used. As far as I know this is the
first publication of this algorithm. Vectorlist is cool :-)

BTW2, this idea is based in part on some fast bitmap rotation code I
did several years ago that is available at:
http://www.oakland.edu/~phkahler
in the graphics demos section. (ya, shameless plug).

Thanks,

--
 ___   __   _   _  _
|   \ /  \ | | | || |       phkahler@oakland.edu     Engineer/Programmer
|  _/| || || |_| || |__     " What makes someone care so much?
|_|  |_||_| \___/ |____)      for things another man can just ignore. " -S.H.
---------------------------------------------------------------------------
** 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 Thu Feb 3 13:15:11 2000

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