www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/02/12/13:00:44

From: tamasiu AT informatik DOT tu-muenchen DOT de (Christian Tamasiu)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Collison detection fo Action game
Date: 12 Feb 1997 11:25:32 GMT
Organization: Technische Universitaet Muenchen, Germany
Lines: 44
Distribution: world
Message-ID: <5ds9bc$j6n@sunsystem5.informatik.tu-muenchen.de>
References: <855142026 DOT 12716 AT dejanews DOT com> <32f87f78 DOT 950435 AT ursa DOT smsu DOT edu> <5drfoc$fub AT irz401 DOT inf DOT tu-dresden DOT de>
NNTP-Posting-Host: hphalle8c.informatik.tu-muenchen.de
Originator: tamasiu AT hphalle8c DOT informatik DOT tu-muenchen DOT de
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

In article <5drfoc$fub AT irz401 DOT inf DOT tu-dresden DOT de>, mk2 AT irz DOT inf DOT tu-dresden DOT de (Mario Koeppen) writes:
|> 
|> In article <32f87f78 DOT 950435 AT ursa DOT smsu DOT edu>, aho450s AT nic DOT smsu DOT edu (Tony O'Bryan) writes:
|> >On Wed, 05 Feb 1997 06:21:03 -0600, tamasiu AT informatik DOT tu-muenchen DOT de wrote:
|> >
|> >>Hi!
|> >>What is the best/fastest way to do collision detection routines for a
|> >>Action game in Allegro?
|> >>Chris.
|> >
|> >The fastest way is probably to check for collision on the four "corners" of each
|> >image rectangle.  However, that leaves a lot to be desired as far as accuracy is
|> >concerned.  One method I use is to store the coordinate outline of each image
|> >and check if two images overlap at any point.  It's more time-consuming, but
|> >it's more accurate.
|> >
|> 
|> Well I think it's quite easy...
|> 
|> You have two sprites a & b (the transparent color is index 0)
|> The coordinates & dimensions should be unsigned long 
|> 
|> 1 check the boundary boxes
|>  1 is (b.x2 < a.x1) or (b.x1 > a.x2)? -> no collision
|>  2 is (b.y2 < a.y1) or (b.y1 > a.y2)? -> no collision
|> 
|> 2 pixel accurate collision detection
|>  1 calculate the overlapping rectangle (x & y offsets in both sprites, with, height and
|>    moduli for both sprites [at least amiga coders should know this term :)])
|> 
|>  2 for all lines (in the overlapping rectangle)
|>     for all pixels
|>       is (a.pixel <> 0) AND (b.pixel <> 0)? -> collision!
|> 
|> I'll write this thing in the next few days in gasm.
|> If there is any demand for the source let me know. I'll post it here then.
|> 
|> -- 
|> Mario Koeppen
|> mk2 AT irz DOT inf DOT tu-dresden DOT de http://www.inf.tu-dresden.de/~mk2

I'd be interested for sure. Please post.
Thanks, Chris.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019