Article View: rec.games.programmer
Article #258Re: Collision detection PLEASE, all geniuses respond!
From: Acacio Cruz [pm]
Date: Tue, 28 Jul 1992 15:59
Date: Tue, 28 Jul 1992 15:59
31 lines
2205 bytes
2205 bytes
From article <1992Jul26.181425.207@micor.ocunix.on.ca>, by goss@micor.ocunix.on.ca (Timothy D. Goss):
> How about this? Create a grid which represents the graphics screen but one
> which does not represent every pixel. Group pixels into 2x2, 4x4 etc groups.
> This grid can be used to represent the approximate location of each sprite or
> background image. To check if a sprite has collided with something simply
> check its destination position in the grid to see if any deadly objects are
> there. The contents of the grid could be id bytes or something. Each time
> a sprite is moved, its position in the grid is also updated.
Here's where some data structures could come in. Its most probable that
the actual array will be mostly empty. So I advise you to use a sparse array
instead. This will reduce the amount of memory consumed.
Well that saves memory but it's a SLOW data structure.\
What he needs is a quad tree wich is fast and eats up very few mem
AND it doesn't force the grid to a fixed dimension and allows
several objects with the form you like even disconnected.
For more info see some books on spatial data structures and use
the quad-tree variant most suited for your app.
Hope this helps,
Acacio Cruz
--
Acacio Justino Calcada da Cruz| BITNET/Internet: axc@fct.unl.pt
Universidade Nova de Lisboa | UUCP: axc@unl.uucp
FCT - Dpto. de Informatica | Fax: (+351) (1) 295-5641
2825 Monte Caparica, PORTUGAL | Phone: (+351) (1) 295-4464
--------------------------------------------------------------
"MOM!"
Technical Details
Message-ID:
<AXC.92Jul28165951@alfa.fct.unl.pt>Path:
arc1-ca.pugleaf.net!sparky!uunet!mcsun!inesc.inesc.pt!dec4pt.puug.pt!unl!unl!axcReferences:
<1992Jul26.181425.207@micor.ocunix.on.ca> <19613@optima.cs.arizona.edu>Show Full Headers
Complete Article Headers
Newsgroups: rec.games.programmer Path: arc1-ca.pugleaf.net!sparky!uunet!mcsun!inesc.inesc.pt!dec4pt.puug.pt!unl!unl!axc From: axc@fct.unl.pt (Acacio Cruz [pm]) Subject: Re: Collision detection PLEASE, all geniuses respond! In-Reply-To: shah@optima.UUCP's message of 27 Jul 92 00:18:40 GMT Message-ID: <AXC.92Jul28165951@alfa.fct.unl.pt> Lines: 31 Sender: news@fct.unl.pt (USENET News System) Organization: Universidade Nova de Lisboa -- Lisbon, Portugal References: <1992Jul26.181425.207@micor.ocunix.on.ca> <19613@optima.cs.arizona.edu> Date: Tue, 28 Jul 1992 15:59:57 GMT Lines: 31