Path: chuka.playstation.co.uk!news From: "Miles Buzzing" Newsgroups: scee.yaroze.programming.2d_graphics Subject: Re: Collision detection with rotating sprites Date: 3 Dec 1998 07:45:43 GMT Organization: PlayStation Net Yaroze (SCEE) Lines: 48 Message-ID: <01be1e90$e7e94160$0a3ddec2@guildfoc> References: <01be1d86$03a1a160$0a3ddec2@guildfoc> <742u50$9lv3@chuka.playstation.co.uk> NNTP-Posting-Host: guildfrd.demon.co.uk X-Newsreader: Microsoft Internet News 4.70.1155 George Bain wrote in article <742u50$9lv3@chuka.playstation.co.uk>... > Hi there, > > Try a bounding sphere. > > George Thanks for the quick response George, but as far as I can see, spheres or boxes the issue is the same. Below is a sample of the code i've since written. 'pS2' is a pointer to an extended sprite structure that can hold details of up to four bounding boxes per sprite. As you can see in the code, if the offset of the collision box (ox/oy) from the centre of the sprite is not equal to zero, then I rotate the bounding box(s) around the sprite's centre. //is bounding box offset from sprite centre if(CollisionRect[iCount1].ox | CollisionRect[iCount1].oy) { //convert the bounding box offset to fixed-point fpCx = TO_FIXED(pS2->CollisionRect[iCount2].ox); fpCy = TO_FIXED(pS2->CollisionRect[iCount2].oy); //rotate it around the sprite z axis iCx = FP_MULTIPLY(fpCx,fp_cos(pS2->gsSprite.rotate)) - FP_MULTIPLY(fpCy,fp_sin(pS2->gsSprite.rotate)); iCy = FP_MULTIPLY(fpCy,fp_cos(pS2->gsSprite.rotate)) + FP_MULTIPLY(fpCx,fp_sin(pS2->gsSprite.rotate)); //back to normal iCx = FROM_FIXED(iCx); iCy = FROM_FIXED(iCy); ............. } The reason I have to do this is that the sprite in question is a rectangle at least twice as long as it is wide - so I use two bounding boxes/spheres. - Miles