Path: chuka.playstation.co.uk!scea!greg_labrec@interactive.sony.com From: Nick Porcino Newsgroups: scea.yaroze.programming.2d_graphics Subject: Re: pixels Date: Wed, 09 Jul 1997 23:07:10 -0800 Organization: SCEA Net Yaroze News Lines: 53 Message-ID: <33C48A1C.3895@bc.sympatico.ca> References: <33c122d9.168381829@news.scea.sony.com> <33c3d7f6.4808700@news.scea.sony.com> NNTP-Posting-Host: vcta01m02-110.bctel.ca Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 3.01-C-SYMPA (Macintosh; I; PPC) Hi Jamin, I thought I'd be a pest... >In article <33c122d9.168381829@news.scea.sony.com>, jamin1@psu.edu (Jamin >Frederick) wrote: > >> Hi, how's it going? I'm working on my pixel-by-pixel collision >> detection algorithm, Have you considered whether a pixel-by-pixel collision detect is *really* necessary? It sounds so time expensive when you could be doing some freaky special effects or better AI or something instead... I've used gobs of weird hacks for collision detection in games, and I've always been able to find a way around pixel-by-pixel. I thought I'd list some of them off: 0. Make your game so intense no one has time to notice that collisions are pixel exact or not. 1. Simple shapes as hit regions - design the art so it fits well into shapes that are easy to mathematically check against, like rectangles, circles, and triangles. 2. Rotated simple shapes as hit regions - sometimes you've got objects that can rotate - rotating a rectangle and checking it against another rotated rectangle is still cheaper than pixel-by-pixel. 3. Stick Figures. Say you've got a figure like a character in a 2d fighter. Make a simple stick figure that mimics the shape and motion of the sprite, ie: a line for the head, a line for upper arm, lower arm, hand, two lines for the torso, etc. etc. Then to do hit detect with the other character in the game all you have to do is treat each line as a fat line and check them against the fat lines in the other character. This has the advantage of letting you know that the hand connected with the noggin. 4. Simple hierarchical shapes. Say you've got a top down view of the TOS U.S.S. Enterprise on the screen. Do your hit detecting on a circle and three rectangles, one for the two engines and one for the engineering hull, with the rectangles of course rotated according to the orientation of the ship on the screen. 5. Polygon shapes. Make a polygon outline that fits around the shape as tightly as you'd like so that game feels good, then check for intersection with collidable objects. If you design it right you can have one complicated polygon collision shape which you test against some trivial shape like a rectangle, but even still, poly-poly intersection is faster than pixel-by-pixel, unless your sprites are really tiny, in which case suggestion number 1. is probably the best IMO. Hope this helps, or gives you some ideas, - nick