Skip to main content
gamedev.net
🔒 Locked

IntersectRect

Started by NightZero 2 replies 450+ views
Original Post
NightZero
NightZero
Hi, Anyone kkows why I dont get IntersectRect to work? Using it for rough collision detection: bool Ghost::contains(RECT r, int xPos) { RECT now; SetRect(&now,x+xPos,y,x+xPos+30,y+30); if(IntersectRect(NULL, &r, &now)) return true; return false; } I printed a debugstring and the cordinates is ok! The method works fine if I pass a point instead and checks if it''s inside a rect... regards, Mattias
Prototype
Prototype
Looks like you forgot an else statement.
Your function always returns false.
Colin Jeanne
Colin Jeanne
quote:
Original post by Prototype
Looks like you forgot an else statement.
Your function always returns false.


No. If IntersectRects() returns true, the next statement - return true - will return from the function as true. No else necessary.

NightZero, the first parameter of IntersectRects() cannot be NULL which is why the function is failing.



The hackers must have gotten into the system through the hyperlink!!
Invader''s Realm
Prototype
Prototype
Uh.. of course you are right.
Silly error.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.