IntersectRect()
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
[email=mwronen@mweb.co.za" onmouseOver="window.status='Mail The_Minister'; return true" onmouseOut="window.status=' '; return true]The_Minister[/email]1C3-D3M0N Interactive
You have it backwards. IntersectRect() returns non-zero if they do intersect, and 0 if they do not.
Sorry my friend, YOU have it backwards . Box wasn''t initialized yet, God I''m such an idiot. Anyways, thanks.
The_Minister
1C3-D3M0N Interactive
The_Minister
1C3-D3M0N Interactive
[email=mwronen@mweb.co.za" onmouseOver="window.status='Mail The_Minister'; return true" onmouseOut="window.status=' '; return true]The_Minister[/email]1C3-D3M0N Interactive
From VC++ 6''s documentation of IntersectRect():
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?
Return ValuesIf 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?
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.
The_Minister
1C3-D3M0N Interactive
Edited by - The_Minister on July 17, 2000 3:50:25 PM
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
[email=mwronen@mweb.co.za" onmouseOver="window.status='Mail The_Minister'; return true" onmouseOut="window.status=' '; return true]The_Minister[/email]1C3-D3M0N Interactive
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement