# 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.

-

Totaly agree with Adam.

Randomness make experience much brighter, but it must me balanced with skill-challenge very nicely, across tons of testing and recalculating.

Naturaly, even skilled player should think like "Yeah, i can handle this" in first few minutes (or longer, depends on your planned gamesession time). But after this, he get in some random event he didn't expect, and both endings (win or lose) are good, like "wow, that was tough, but i realy rule in this game" or "omg, i've seen that, but it was so hard to win here. i think, i should try to do this again", but not too often too. And yeah, if this randomness will happen to often, this will lead to something like "okay, it's all challenge this game can give. boooring!" or "c'mon! i can't handle anything, this game just kick me in * all the time! i will look for something else now".

Also, not so close to question, but it realy matters how your game behave itself with player. If it's not the main plan of your design, then better your game to be "kind" - don't punish player everytime he does mistakes. So - black holes? Ok, but don't punish your player too much with them. Give him a chance once a session (or a random chance, lol) to fix his mistakes, to try to play harder without "death", without need to restart. Maybe health regen (hello, CoD:MW), or maybe chance to gather enough points for new "heart/life" in health bar in this one session

It looks like a great idea - different results for same "collision" event. It should add some "various gameplay" experience on only one event, which is good - simplier the gameplay - better.

-