Path: chuka.playstation.co.uk!news From: James Shaughnessy Newsgroups: scee.yaroze.programming.2d_graphics Subject: Re: 2d collision bounding box... Date: Wed, 09 Dec 1998 00:42:38 +0000 Organization: PlayStation Net Yaroze (SCEE) Lines: 90 Message-ID: <366DC77E.250F58BA@manc.u-net.com> References: <366C2C7E.75028A95@club-internet.fr> <74hp72$8bc3@chuka.playstation.co.uk> NNTP-Posting-Host: manc.u-net.com Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="------------A03C9485937A742C4D05BBE6" X-Mailer: Mozilla 4.5 [en] (Win95; I) X-Accept-Language: en --------------A03C9485937A742C4D05BBE6 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Collision detection in Gravitation is done in a completely stupid way, but it works. A 15x15 area of VRAM is SaveImage'd to main RAM, and the ship pixels are drawn on manually checking first if the pixel (16-bit word) underneath is non-zero. Then, when it's done that it's LoadImage'd it back to VRAM with a return flag saying if the ship has hit anything. I think it would be difficult to see this looking at the source, unless my commenting is particularly spicy. (bear in mind the ships are of course not actually GsSprites) The sane way to do it would be to draw the ships using sprites as usual, but have copies of the sprites in arrays (perhaps in 1-bit form) and check the pixels using bit masking (with &). This would prove much faster (as the collision detection is not time-dependant on the actual GPU drawing). This is the way I do bullet-background collisions (bullets are actually 1x1 sprites) -- the 640x512 maps are stored in a 1-bit 40K area of RAM (created runtime as the map is being decompressed) The best thing to do though is to use the bounding box method to test whether it's worth then doing a pixel-perfect test. Later, Jim PS Sorry for the stupid layouting, just experimenting with Netscape 4.5 which I'm only keeping because it allows me to DISABLE THOSE BLOODY COOKIES which are the work of the devil. PPS I'm having REAL problems getting a large map to scroll on the GameBoy -- the LCD controller stops you from accessing VRAM for most of the time... oops sorry this don't belong here! (But anyone interested let me know..) Rad wrote: > I'll get around to coding some collision detection during the christmas > holidays so untill then I can't really help you out, but my suggestion would > be to check out the source code to James Shaughnessy's excellent Gravitation > (http://www.netyaroze-europe.com/~shaughnj/ftp/gravsrc.zip) which uses > pixel-perfect collision detection. --------------A03C9485937A742C4D05BBE6 Content-Type: text/html; charset=us-ascii Content-Transfer-Encoding: 7bit Collision detection in Gravitation is done in a completely stupid way, but it works.  A 15x15 area of VRAM is SaveImage'd to main RAM, and the ship pixels are drawn on manually checking first if the pixel (16-bit word) underneath is non-zero. Then, when it's done that it's LoadImage'd it back to VRAM with a return flag saying if the ship has hit anything.  I think it would be difficult to see this looking at the source, unless my commenting is particularly spicy.  (bear in mind the ships are of course not actually GsSprites)

The sane way to do it would be to draw the ships using sprites as usual, but have copies of the sprites in arrays (perhaps in 1-bit form) and check the pixels using bit masking (with &).    This would prove much faster (as the collision detection is not time-dependant on the actual GPU drawing).  This is the way I do bullet-background collisions (bullets are actually 1x1 sprites) -- the 640x512 maps are stored in a 1-bit 40K area of RAM (created runtime as the map is being decompressed)

The best thing to do though is to use the bounding box method to test whether it's worth then doing a pixel-perfect test.

Later,
Jim

PS Sorry for the stupid layouting, just experimenting with Netscape 4.5 which I'm only keeping because it allows me to DISABLE THOSE BLOODY COOKIES which are the work of the devil.
PPS I'm having REAL problems getting a large map to scroll on the GameBoy -- the LCD controller stops you from accessing VRAM for most of the time... oops sorry this don't belong here! (But anyone interested let me know..)

Rad wrote:

I'll get around to coding some collision detection during the christmas
holidays so untill then I can't really help you out, but my suggestion would
be to check out the source code to James Shaughnessy's excellent Gravitation
(http://www.netyaroze-europe.com/~shaughnj/ftp/gravsrc.zip) which uses
pixel-perfect collision detection.
--------------A03C9485937A742C4D05BBE6--