title: visual c++ RECT collision
body: <p>I have just started with Win32 GUI programming, a few days ago. I am trying to make a simple game in which I need to detect collision between 2 objects.
  So I made my <em>characters</em> using <code>RECT</code> struct</p>
  
  <p>To detect if they collide I have used:</p>
  
  <pre><code>// Returns 1 if the point (x, y) lies within the rectangle, 0 otherwise
  int is_point_in_rectangle(RECT r, int x, int y) {
      if ((r.left   &lt;= x &amp;&amp; r.right &gt;= x) &amp;&amp;
          (r.bottom &lt;= y &amp;&amp; r.top   &gt;= y))
          return 1;
      return 0;
  }
  
  // Returns 1 if the rectangles overlap, 0 otherwise
  int do_rectangles_intersect(RECT a, RECT b) {
      if ( is_point_in_rectangle(a, b.left , b.top   ) ||
           is_point_in_rectangle(a, b.right, b.top   ) ||
           is_point_in_rectangle(a, b.left , b.bottom) ||
           is_point_in_rectangle(a, b.right, b.bottom))
          return 1;
      if ( is_point_in_rectangle(b, a.left , a.top   ) ||
           is_point_in_rectangle(b, a.right, a.top   ) ||
           is_point_in_rectangle(b, a.left , a.bottom) ||
           is_point_in_rectangle(b, a.right, a.bottom))
          return 1;
      return 0;
  }
  </code></pre>
  
  <p>Which I found on a question here, and it seems to work for situations like <a href="http://puu.sh/2loUa" rel="nofollow">this</a>. But there is a small problem with it this situation <a href="http://puu.sh/2loVS" rel="nofollow">here</a></p>
  
  <p>Is there any way to fix that? Am I doing it wrong? Should I try a different approach?
  Any tip will help.</p>