Mail Archives: djgpp/1997/10/04/17:32:25

From: David Jenkins <me AT jenkinsdavid DOT demon DOT co DOT uk>
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>
<Pine DOT SUN DOT 3 DOT 95 DOT 971001070727 DOT 12351A-100000 AT ernie DOT eecs DOT uic DOT edu>
MIME-Version: 1.0
Lines: 29
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

>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

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.

-- for C programmers.
David Jenkins

- Raw text -

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