title: Calculating collisions, taking into account velocity
body: <p>I'm making a platformer game. The jumping and movement are working, and now I want to program the collisions. I have a sort of idea as to how this will work:</p>
  
  <p><em>I wasn't sure whether this question should be here or in the game dev site.</em></p>
  
  <ol>
  <li><p>I have two Vector2's - velo and momentum (velo is the velocity). Both are (0, 0). The momentum is what's added to the velocity each frame.</p></li>
  <li><p>Each frame, I first get the input. Momentum is increased and/or increased based on the keys pressed (e.g: <code>if (Gdx.input.isKeyPressed(Keys.A)) { momentum.x -= speed; }</code>)</p></li>
  <li><p>I then multiply the momentum by 0.15. This is so that it slows down.</p></li>
  <li><p>After this, I multiply the velocity by 0.8.</p></li>
  <li><p>Then, I <em>add</em> the momentum to the velocity, to increase the velocity, as 
  this is what actually moves the player.</p></li>
  <li><p>I then add the velocity to the position of the player.</p></li>
  <li><p>To apply the gravity, I add a gravity vector (0, -10) to the position of the player.</p></li>
  </ol>
  
  <p>So I need to find a way to move the player, but not allowing it to overlap any part of the world. The world is made up of lots of <code>Rectangle</code> instances. The player's body is also an instance of <code>Rectangle</code>. Would it be easier to rewrite the collisions using Box2D? What I've tried is checking if the player overlaps any rectangles when it's moved, and if it will, not moving it. <br>But this doesn't seem to take everything into account - sometimes it works, but other times, it stops before touching the world.
  <br><br>
  <strong>TL;DR:</strong> I want to make collisions of my player with a world which is stored as a grid of rectangles. How would I do this, as my player is also a Rectangle. Would it be easier to use Box2D?</p>