collision detection
Yo, I'm making pong, and it's almost finished, exept my collision
detecttion is messed up. It's detecting a collision with one paddle in the middle of the screen. I used some really wierd math (deltas, midpoints, etc.) and my friend said it was too complex, and I should think of another way to do it, but i can't think of another way to do it, so how do I detect a collision between RECTs?
Hibiki
Wheres the any key?
[EDIT] Oh yea, using C++, DDraw7 and DInput8.
[edited by - hibiki_konzaki on June 21, 2002 2:56:31 PM]
HibikiWheres the any key?www.geocities.com/dragongames123/home.html
find your elementat mutedfaith.com.<º>
find your elementat mutedfaith.com.<º>
win32 PointInRect()
or maybe it was ptinrect.. i dont remember, i''ve
written my own detection code since the last time i''ve
had to use it.
-eldee
;another space monkey;
[ Forced Evolution Studios ]
or maybe it was ptinrect.. i dont remember, i''ve
written my own detection code since the last time i''ve
had to use it.
-eldee
;another space monkey;
[ Forced Evolution Studios ]
-eldee;another space monkey;[ Forced Evolution Studios ]
>>so how do I detect a collision between RECTs?
( Out of my sprite lib. )
P.S. Learned it from John Amato''s collision algos in the resources section. Great article.
Guy
( Out of my sprite lib. )
short int Sprite_Rect_Collide ( SPRITE *ptr, RECT rect ){ int left1, right1; int top1, bottom1; left1 = ptr -> x_pos; right1 = ptr -> x_pos + ptr -> frame_width; top1 = ptr -> y_pos; bottom1 = ptr -> y_pos + ptr -> frame_height; if ( bottom1 < rect.top ) return (0); if ( top1 > rect.bottom ) return (0); if ( right1 < rect.left ) return (0); if ( left1 > rect.right ) return (0); return(1);}// end Sprite_Rect_Collide
P.S. Learned it from John Amato''s collision algos in the resources section. Great article.
Guy
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement