Monday, April 15, 2013

Physics Engine Breakdown

So. I created my own physics system for the sidescrolling aspect of the game, to reduce the number of bugs. Just as with Minecraft; the more simple the world resolution, the less possible areas your character object can be. Minecraft exists on a 3D grid constructed of blocks. For low res games like this, less precision needs to be coded into collision checking. Because the programmer knows that the collision between the player and the block will be confined to that grid, they can program a sort of "movement/physics anticipation" that GREATLY reduces the risk of non-clipping game object. This is usually not a required step, but it certainly helps when there are hundreds of other game objects that alter the relative position, speed, friction, impulses, and forces of the character (IE a spring, a speed boost pad, a chainsaw blade that comes out of the ground, etc).

I programmed in this "movement/physics anticipation" into this game. However, because of the nature of the level creation, I made all the blocks lock to an 8x8 pixel grid. A mistake? Maybe so. In light of this, there was absolutely NO way to "no clip" in the game. Believe me, I tried for hours and hours. Blocks stayed blocks, and open air stayed open air: Zero overlap, no matter what speed the player went.

However, a problem arose when I added a block that did not adhere to the grid. Obviously, since this was a product of having a safe system for the anti-clipping, I kept it as is. I just edited the levels in an 8x8 grid to ensure that the character never ended up like the one in the illustration below:




This certainly presented a problem. Having a game restricted
to an 8x8 grid can make the levels feel rather constrained...

========================================================================

TODAY I FIXED THIS PROBLEM.

That means I can add loads of amazing features to this game. I am not even slightly limited by the types of physics objects I can include! I can have as many SPRINGS, EXPLOSIONS, BARRELS, etc. that I want, doing anything I want! They could launch the character directly into the corner of a block from 3 pixels away at a speed of 32 pixels per frame (60FPS), and it would STILL not break my system.

I tested it. It works. I just reduced the number of rules for creating the levels in this game.

Hmm... An enemy that drops random bombs which launch you at ridiculous speeds in random directions is now possible... Just a thought.

No comments:

Post a Comment