title: 2D Collision Reaction
body: <p>I have been looking around on forums and i haven't been able to find anything specific enough for what i am having trouble with. I am trying to make a function for collision detection in a 2D platformer, and at first i could make it work with explicitly naming every vertex and it where the player would then move to upon collision, but that was not efficient at all and ended up with alot of retyping things. It would work at first but over time it would become more of a hassle than it is worth. I am trying to make a collision detection function that will be able to tell me which side the player is colliding on and that will be able to move the character to the proper position. I am using allegro 5 and c++ and this is my function thus far:</p>
  
  <pre><code>bool Collision(int x1,int y1,int h1,int w1,int x2,int y2,int h2,int w2){
  
      if(x1 &lt; x2 + w2 &amp;&amp;
         x2 &lt; x1 + w1 &amp;&amp;
         y1 &lt; y2 + h2 &amp;&amp;
         y2 &lt; y1 + h1)
         {return 1;}
  
      return 0;
  }
  </code></pre>
  
  <p>how could i make it so that upon collision my object will stop and not continue through the object? but also know that it has landed on top of something, or hit the side or bottom of it because those would each be different reactions.</p>