# Handling Block Collisions

The title isn't great, but let me try and explain my problem. I'm working on a little game at the moment the gist of which is that you're an entity in this 2-D world and you have to dodge obstacles. These obstacles approach form all 4 directions and you're stuck in the middle and simply have to survive as long as you can without dying (from hitting the walls, obstacles, etc.) Right now, my problem is this:

The obstacles are randomly generated, so they often collide with obstacles coming from the other directions. I feel like something should happens when they collide, but I don't really know what to do with them. Ideally, I would have the blocks generate such that they never collide, however this as proven to be both mathematically and computationally difficult. I'd still like to get this to happen if possible (if you have any clever tricks let me know) but I'm willing to consider other ideas as well. One thing that sounded cool to me was that upon collision, and explosion happens that abruptly shoves your entity away from the collision and deals a little damage. Conversely, a "black hole" could form and suck you towards the collision possibly dragging you into oncoming obstacles, etc. The problem I have with both of these ideas is that they're random. So there's no guarantee that it'll be consistent between play throughs. Seeing as they could potentially deal damage to the entity, it seems unfair. One person could have a significantly easier time than another because there were no collisions. Am I right to have these concerns? Or does the randomness add to the fun of things? Any ideas on how I could fairly handle such collisions?

Thanks!

If you approximate the obstacles with bounding spheres, then testing a new obstacle to see if it might collide with any existing obstacle is not too hard. http://twobitcoder.blogspot.co.uk/2010/04/circle-collision-detection.html explains the process well.

All you need to add on to that is some tests to make sure the position at the collision time (if there is one) is inside the play area.

As for determining which option is most fun, I'd suggest implementing each option and trying them, although in general I'd say that giving random numbers too much influence on how well the player does is usually a bad idea - you want the player to feel they have control over how well they do.