Skip to main content
gamedev.net
🔒 Locked

Simple Collision detection using rect refresher please!

Started by Vanz Apr 9, 2002 at 1:03 PM 0 replies 150+ views
Original Post
Vanz
Vanz
Could someone please refresh my memory on how to do the collision detection for two bodies defined by the rect structure. I remeber it being really clean looking something like: RECT body1, body2 Body1.left=100; Body1.top=100; . . .etc define bodies if (Body1||Body2) ... something like this but can''t remeber or find on internet Thanks. Rob PS. I just remember it looked very clean and did not involve: if ((Body1.left>Body2.left)&&(Body1.right ..etc
kaveh
kaveh
int collision(RECT *a, RECT *b)
{
if (a->bottom < b->top) return(0);
if (a->top > b->bottom) return(0);
if (a->right < b->left) return(0);
if (a->left > b->right) return(0);

return(1);
};
------------------------Kicking Software

Topic Locked

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

Sign in to reply to this topic.