From: David Jenkins Newsgroups: comp.os.msdos.djgpp Subject: Re: collision detection Date: Thu, 2 Oct 1997 01:38:34 +0100 Organization: None Distribution: world Message-ID: References: <34327EAC AT relay DOT probe DOT co DOT uk> NNTP-Posting-Host: jenkinsdavid.demon.co.uk MIME-Version: 1.0 Lines: 29 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk > >Thanks a lot it works. Would you by any chance also know how to detect a >rectangle with a circle. Let's say we have: > >typedef struct CIR { > int x1, int y1; > int radius; >} CIR; > >and then do detect in RECT lies in some point in CIR. Any help would be >appreciated. > Dunno about this, I've never tried it, in my game the "enemy" sprites are all round, the player is rectangular. I use distance checking for enemy to enemy and bullet to enemy, for player to enemy I just use bounding boxes. I suppose I could use the four corners of the players bounding box figure out which is closest to the enemy then distance check this corner point with the enemy. But just using bounding boxes seems to need less maths, so more speed. BTW the source code for the game I refer to is available for download on my site, URL below. -- http://www.jenkinsdavid.demon.co.uk for C programmers. David Jenkins