Archived

This topic is now archived and is closed to further replies.

IntersectRect()

This topic is 6361 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

In my code, I check if a projectile is not where the user can see it. If so, I destroy it. As with all my collision detection so far, I am trying to use IntersectRect to determine if the projectile''s bounding box is colliding with the screen (or camera, as I actually have a moving camera). As far as I know, if the two RECTs specified are colliding, the return value is non-zero. Otherwise, it is zero. Which leads me to wonder why it doesn''t work. My code looks like this: if (IntersectRect(&Dummy, &Box, Camera) == 0) Destroy(); RECT Dummy is a dummy parameter, which IntersectRect fills with the coordinates of the intersection. RECT Box is the projectile''s bounding box. RECT *Camera is the camera itself. Destroy() destroys the projectile. Projectiles are always immediatly destroyed after creation, and I''ve traced it down to this code. When commented out, the game works correctly aside from projectiles sailing up into the heavens, which will eventually cause an access violation. Any help would be greatly appreciated. Thanks. The_Minister 1C3-D3M0N Interactive

Share this post


Link to post
Share on other sites
From VC++ 6''s documentation of IntersectRect():

Return Values
If the rectangles intersect, the return value is nonzero.

If the rectangles do not intersect, the return value is zero.

Microsoft is not known for being the best documentation writers around, but I''m suprised to hear that it''s backwards. What does the rest of your code look like?

Share this post


Link to post
Share on other sites
Hmm sorry I have read your reply incorrectly. I simply read the part that I have it backwards, and I assumed that you mean the opposite of what I had said... you merely told me I had it backwads and then wrote the same words I did.

quote:


As far as I know, if the two RECTs specified are colliding, the return value is non-zero. Otherwise, it is zero. Which leads me to wonder why it doesn't work.




The_Minister
1C3-D3M0N Interactive

Edited by - The_Minister on July 17, 2000 3:50:25 PM

Share this post


Link to post
Share on other sites