How will the velocities of two moving objects change once they collide?

I'm making a small game where things can fly around and collide. Things like boxes and so on. For each object, I have an array of all forces acting upon it, I have it's mass, it's position and it's velocity in both directions (a 2D vector). I know how to detect collision between them, but I just don't know how to react.

I used to calculate their orientation towards each other, it they were on top one another, I would just negate their y speed (v.y = -v.y), and if they were next to each other on the x axis I would negate their x speed (v.x = -v.x).

Now, this isn't very realistic, so, how do I do it? All objects are rectangles represented by [x, y, w, h] vectors.

Objects can't rotate.

• If you want it to be realistic you're going to have to use physics equations and transfer the forces between the colliding objects. This may be fairly easy since they can't rotate and it's 2D. Depending on how complex you plan to make it though, you may want to consider using a physics engine like Box2D or Farseer. – Richard Marskell - Drackir Apr 16 '12 at 19:18