Friday, July 22, 2011

What To Learn From Dark

I always wanted to do a 2D side scroller shooter and I though this would be a great time to start with one. I used Allegro and Dev C++ and was very comfortable with them, so with permission to use an external library from my school teacher I started working on Dark.

I wanted something like a 2D Assassins Creed loaded with guns and fully procedural character animations and fast paced action. I first figured out an IK solver to create bones for my characters then put them together to make a walking bipedal. After that was done I started trying out different techniques to create a procedural animation system that would make the dead collection of bones come to life. I failed. I came up with some very simple walking animations that worked on footsteps calculated by analyzing the structure of the terrain underneath but never got it to look acceptable. I even tried to turn it into a ragdoll which would balance itself by applying it's own muscular forces, like a ragdoll with a brain, which obviously didn't work out. All that time didn't go to waste though, I ended up using the ragdoll after the characters died, with springs connecting the feet to the pelvis for a more natural fall unlike a traditional ragdoll. After spending countless hours on that system, I gave up and made a small application that allowed me to save and load keyframed animations. After implementing keyframed animations, I tried to turn it into a semi procedural animation system where the character would not let any bones cut through the world.

With all the worlds made out of lines, I made an object editor that allowed me to create simple objects and import them into the map editor. These objects also included guns that the player and other NPCs carried. To create reloading animations, I also tagged weapon objects with color coded parts which moved when the right hand of the character approached it in the reloading animation. So the barrel of the gun moved as the player reloaded the weapon after replacing the old clip that fell to the ground.

Which reminds me, I also tried to incorporate a 2D physics simulator into my game that allowed these objects to move and fall when shot, you could even make chandeliers by sticking objects to the background with strings and springs. The physics engine never reached it's final stages, I never implemented impulses and contact normal forces which made the objects act funny. I wouldn't discover and understand the Runge Kutta numerical method for another year for the suspensions in Velocita.

The game was still bland, there were many other things to add and time was running out. I made breakable objects like glass and wood which were again just simple lines which took damage. With a little clever trigonometry I had pieces of wood flying off the surfaces from the point of contact to make a hole in the wall.  Talking about dynamic objects in the world, the particle system was fun for the smoke and the shells coming out of the gun, but they just weren't what I wanted for the blood. There had do be amazing blood in the game for good feedback to the player. I like to call it rope physics, but really, they were a set of particles connected with strings, bright red strings, which replaced the bullet after it made contact with the enemy, so that after you've taken your last shot, and you're falling to the ground in slow motion, you can see the the blood spray behind your character.

There is much to learn from this game. Most importantly, Box2D and Chipmunk are great physics simulation libraries! Recreating something that's already been done is good if you want to learn how it's made but if you care more about your game then choose whats best for the application.

If I was told to find the missing ingredient in the project, I would say that it's design. The project started off without a design written down on paper. My brain is the last place I'd choose to keep an idea, because after a little while, it's not the very same idea you originally had. With the initial goal to create a free running platformer, I ended up building a simple shooter with sloppy physics, overdone effects, and ugly animations. There were countless bugs too, untraceable and very irritating. I never even started with making the final levels of the game. All I have is five tutorias to show off all the features of the game.