Monday, February 11, 2013

progress

Ok, it's been too long since I updated this.  I've been frustrated with kyuplex lately because I am bordering on analysis paralysis.  I've been experimenting with different designs for entities, kxCubes, and the level processing system with scene/entity save/loading.  Perhaps I've spent too much time trying to design the perfect system, rather than making progress towards content dev.  My excuse is that the foundation is the most important part, because once I get too deep into content, it will probably be too hard to go back and change things.

I've been struggling to move toward more encapsulation.  I've been reading Scott Meyers' Effective C++ and realized that my classes were committing the noobish error of abusing the singleton pattern to create a reference to all variables in the main class scope.  Also trying to find a balance between creating my own self-standing classes and integrating with my rendering and scene manager, Irrlicht.  I've gone back and forth a couple times between different versions of my base class; kxCube.

But I think I've finally reached a point where I feel that my current design is enough of a compromise to move forward, and deal with whatever problems crop up in the future.

Most recently finished refactoring (for the nth time) the kxCollectable class.  It is mostly encapsulated, with just one usage of the singleton instance to access my physics world.  Like this:














































Line 36.
I wanted to keep btCollisionObject pointer with the irrlicht node, and it's constructor seemed like the most logical place to put construction of the collision object.  I'd decided to break the encapsulation of the kxCollectable class rather than my kxSceneNodeFactory class.  It is only one usage of the singleton, so you could say it is a single singleton : )

Also, I spent a lot of time refactoring level loading.  I've separated level files into two formats: .kxe and kxs
kxs is the irrlicht default scene xml format.  I use it for level geometry mostly, with smgr->saveScene/loadScene methods.  These are built into irrlicht, so they are like a black box unless I completely redefine them.  I did define my own loading/saving methods though, so to not waste them I separated all entities into the .kxe files.  So now level loading is a two part process, loading the irrlicht nodes and level geo with the default functionality, and then loading entities with my custom methods and files.
And as a by-product of refactoring this way,  I was able to generalize the ProcessLevel method, and am now set up to load 'waves' of entities as the level progresses.

No comments:

Post a Comment