title: Allegro 5 Bounding Box Detection
body: <p>My bounding box detection is off. It detects collision when the boxes are "close" but not touching. Here is the relevant part off my code.</p>
  
  <pre><code>if(bounding_box_collision(playerOne.x, playerOne.y, playerOne.x + 15, playerOne.y + 15,         foodx, foody, foodx + 10, foody + 10))
  {
      cout &lt;&lt; "Collision" &lt;&lt; endl;
      playerOne.score += 1;
      foodx = rand() % 786;
      int foody = rand() % 586;
  }
  </code></pre>
  
  <p>And here is "bounding_box_collison" I had my own function but it wasn't working so I copy pasted one off the allegro wiki here <a href="http://wiki.allegro.cc/index.php?title=Bounding_Box" rel="nofollow">http://wiki.allegro.cc/index.php?title=Bounding_Box</a>. I still have the same problem.</p>
  
  <pre><code>int bounding_box_collision(int b1_x, int b1_y, int b1_w, int b1_h, int b2_x, int b2_y, int b2_w, int b2_h)
  {
       if ((b1_x &gt; b2_x + b2_w - 1) || // is b1 on the right side of b2?
          (b1_y &gt; b2_y + b2_h - 1) || // is b1 under b2?
          (b2_x &gt; b1_x + b1_w - 1) || // is b2 on the right side of b1?
          (b2_y &gt; b1_y + b1_h - 1))   // is b2 under b1?
       {
      // no collision
      return false;
  }
  
      // collision
      return true;
   }
  </code></pre>