In my 2d pixel old-school platformer, I'm looking for methods for bouncing particles off of background tiles. Particles aren't affected by gravity and collisions are "reflective". By that I mean a particle hitting the side of a square tile at 45 degrees should bounce off at 45 degrees as well.

We can assume that tiles will always be perfectly square. No slopes or anything.

What are efficient methods and algorithms to do this? I'd be implementing this on a Sega Genesis.


When testing a particle to see if it's hit a block, you'll usually know if it hits a side or top or bottom.

If you express the velocity of the particle as a delta_x and delta_y, you can invert an individual axis when hitting a wall.

For instance, if you hit a vertical surface, invert the x-axis, and the y-axis if it was a horizontal surface.

| improve this answer | |
  • 1
    \$\begingroup\$ A refinement on this is to not invert the axis but rather reset the sign appropriately (x = abs(x) or x = -abs(x)). Inverting means that if a particle gets in a bad position inside an object it will jitter and not escape, which is a very visible glitch. \$\endgroup\$ – Kevin Reid Apr 28 '12 at 13:09

In a perfectly reflective collision, the angle of reflection is equal to the angle of incidence reflected over the surface normal.

I'm not sure if I'm understanding your question in its entirety, but assuming you have access to the surface normal at the point of contact and the particles' movement vectors, it should be as simple as reflecting one vector over the other according to this formula:

Vr = Vi - 2(N dot Vi) * N

Where N is the normal vector, Vr is the reflected vector and Vi is the incident vector. Hope that helps!

| improve this answer | |
  • \$\begingroup\$ Thanks for your answer. Unfortunately, it's not exactly what I'm looking for. In my case I'm working with a very low power CPU (Sega Genesis 68000 running at 7mhz) and doing all those dot products and multiplications and normal calculations are going to be bog slow. I'll try to clear up my question to better explain what I need. \$\endgroup\$ – DJCouchyCouch Mar 29 '12 at 13:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.