Wednesday, November 16, 2011

SmashPc: The Postmortem

When I set out to make SmashPC, the main point was to try and share the ease of making a 2D game using SFML, chipmunk-physics, tinyxml, and Gleed2d.

For this post, I'll go over the main points, and cover some of the improvements I could have done.

Overview of the Main Points

To me, the biggest point I want to make is how a 2d physics engine makes writing games a snap.  No longer do I have to handle moving every object within the world, checking all the collision possibilities, handling the odd collision detection issues we used to have, or any other number of things.  Sure, there was a time when it was "fun" to handle all that stuff, but it seriously impeded making a cool game.

Instead, we tell the physics engine what object are in the world; their mass, force, angle, rotational velocity, friction  and all the other physical properties.  We tell the physics engine to notify us when certain objects collide, so we can do fun stuff with them.  Then, we basically say, "Go", and it goes.  With little effort, I had 200 enemies all running towards me, pushing each other around, in a natural group.  I think it's really cool stuff.

I also really like the power SFML provides.  It makes doing anything you want with sprites a snap (scaling, rotation, etc.).  Input is handled easily, and sound is very well done.  I didn't even bother with the spatial sound available, but it's another strong reason to use SFML.

Throw in tinyxml, to handle parsing all the data, and gleed2d, for creating the levels, and saving them in XML, and you have the recipe for making games very easily.

What I could have done better

The first thing I want to point out is the lack of a proper design before I began coding.  I had an idea of what I wanted, but nothing concrete.  I didn't always write code with the end result in mind, and that caused me to do some re-writes a few times (ie, adding the PhysicalObject parent class, and moving all objects to the SmashPcData class).  This also added to my other issues.

I should have used xml to detail enemies; instead, I just wrote the properties in the SmashPcEnemy class (Their speed, movement update time, etc.).  This would also have been used to define what items are released by the "special" enemy; instead, I just hard-coded it in the SmashPcData class.

I would re-do the GameLevel class.  Initially, I included the option to add items to the map, but I didn't once use it.  That caused me to waste some time and code.

I would like to re-do the weapons class.  How I handled switching between bullets was poor.

Final Word

In the end, I just wanted to get it out, and I took some short-cuts to get there, but, I think the main point of this blog was fulfilled.  I hope I showed how you can use the tools to make interesting 2D games.

I may use this blog for other games I make.  I'm thinking of a side-scroller type game, kinda like the Contra games.  We'll just have to see.

Until then!


  1. Great blog! I enjoy reading it and I hope you write more about other games you make :)

  2. I countenance, I make not been on this webpage in a ensbobetdless time? withal it was added feeling to see It is such an vital content and ignored by so numerous, alter professionals. I thsboank you to service making grouping more alive of practical issueExcellent whatsis as exemplary.