|
-
Oct 26th, 2001, 01:39 PM
#1
IntersectRect?
I've searched this message board for a couple days and still don't get how the IntersectRect API works. I'm doing some simple rectangular collison detection and I don't understand the parameters of the API:
Declare Function IntersectRect Lib "user32" (lpDestRect As RECT, lpSrc1Rect As RECT, lpSrc2Rect As RECT) As Long
What does the Destination Rectangle do/look like?
I've defined RECT (TOP,BOTTOM,LEFT,RIGHT as long) as a type, is that right?
Here is all my object collision code:
Code:
Dim TempRect as RECT
If IntersectRect(TempRect, BLOCKS(i).POINTS, BALLS(j).POINTS) <> 0 And BLOCKS(i).HIT > 0 Then
TempRect is a dummy varible, it has no value unless IntersectRect gives it to it.
.POINTS are defined as RECT...
The ball just passes through the block, never "hitting" them.
Anyone know what's wrong?
-
Oct 26th, 2001, 03:00 PM
#2
Frenzied Member
Forget about that, use the good old VB function that NEVER gives you any problems 
VB Code:
If Obj1.Right>=Obj2.Left And Obj1.Left<=Obj2.Right And Obj1.Bottom>=Obj2.Top And Obj1.Top<=Obj2.Bottom Then
'We've got a collision! :)
End If
-
Oct 26th, 2001, 03:59 PM
#3
API is faster, Jotaf. You can do anything in VB... its just a whole lot slower =).
If you remove the "And Blocks..." part, it might work. What is that for?
Also, a RECT is defined as:
Code:
Type RECT
Left as Long
Top as Long
Right as Long
Bottom as Long
End Type
This is actually very important. If you dont have it this way, change it, and it might solve your problem right there. Otherwise, your code looks fine.
Z.
-
Oct 27th, 2001, 09:55 AM
#4
Thank you. This is for a Breakout clone. I guess I have a problem somewhere else...
Oh yeah, I had it declared like you said. I was just to lazy to post it like that.
Thanks again for all your help!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|