Jaa


Don’t reinvent those wheels

Still continuing on about my AppWeek game, another bit that really helped me out was leveraging existing code for pieces of the game I didn’t really know how to make in a short time. While I do have a decent amount of generic code I’ve accumulated over the years, there are some pieces that I pulled together to make some aspects of the game easier.

The first piece of code was to grab my EasyConfig library, which is a simple three-class library for parsing INI files. I used these INI files to define how each gun behaved, what it looked like, and what sounds it made. The files contained things like damage done, rounds per clip, max ammo, and, for the grenade, the damage falloff exponent so the damage decreased over time. While this code is code I’ve written, I mention it here because it is publicly available to anyone that wants to quickly drop in support for INI files.

The next piece I grabbed was the BoxCollider library from Fabio Policarpo’s FPS demo (available as a download on this page: https://fabio.policarpo.nom.br/Demos.html). BoxCollider is a great little library for handling collisions between boxes, rays, and triangulated meshes. I used the library for the character movement collision as well as to handle raycasting for the guns and the collision portion of my grenade physics (I handled the dynamics myself and just did bouncing; the grenades actually never rotate or roll). I did do a few passes over the code base to optimize some of the methods and remove a few parts that created garbage, but it’s still a very valuable library without those changes.

I also needed to make my grenades go boom, so I snagged the Particle 3D sample and dropped that in. With minor changes just to the size of the particles, the built in explosion effect quickly became the look for my grenades. Is it realistic? No, but then again a giant fireball is way cooler to watch than a bunch of tiny pieces of metal flying around.

What’s the moral here? If you’re trying to actually finish a game, I recommend taking a bit to search around for pieces of code you can leverage to make your development quicker and smoother.

Comments

  • Anonymous
    October 06, 2010
    I can understand reusing one's own in-house code, or using someone else's code as a means of learning, but is it really a good idea to suggest that developers simply find and use another person's code for their own profitable projects? If that's what you did; you didn't make a first person shooter, you remixed another.

  • Anonymous
    October 06, 2010
    I can understand reusing one's own in-house code, or using someone else's code as a means of learning, but is it really a good idea to suggest that developers simply find and use another person's code for their own profitable projects? If that's what you did; you didn't make a first person shooter, you remixed another.

  • Anonymous
    October 06, 2010
    Sorry for the double; I wasn't trying to be rude and flood your blog :( blush Just an honest opinion from a fellow programmer.

  • Anonymous
    October 06, 2010
    The comment has been removed

  • Anonymous
    October 28, 2010
    A more valid concern would be the license of the reused code.  Not everything that is free is actually free.