wrote a system for loading keymappings from file. The number of config files my game will use is rapidly growing. the file looks like this:
This lets me have more than one keymapping, and lets users customise their keymappings with little effort from myself. I could provide an in-game interface later if I wish.
refactored the system so the world is spawning objects and the scene is only aware of what to draw. Thusly, each entity has different and unrelated data structures within each system, and systems communicate between each other via event queues. This loose coupling makes refactoring easy
Created a factory system for spawning a "Thing" from a prototype, just by its name. This loads from a text file like this:
PROTOTYPE NAME "TV" WEIGHT 35.0 MODEL "TV" SCRIPT "TV" /PROTOTYPE
PROTOTYPE NAME "broom" WEIGHT 2.0 MODEL "broom" SCRIPT "broom" /PROTOTYPE
PROTOTYPE NAME "safety_stick" WEIGHT 4.0 MODEL "safety_stick" SCRIPT "safety_stick" /PROTOTYPE
PROTOTYPE NAME "bench" WEIGHT 150.0 MODEL "bench" SCRIPT "chair3" /PROTOTYPE
PROTOTYPE NAME "street lamp" WEIGHT 300.0 MODEL "street lamp" SCRIPT "street lamp" /PROTOTYPE
PROTOTYPE NAME "cine_camera" WEIGHT 45.0 MODEL "cine_camera" SCRIPT "cine camera" /PROTOTYPE
PROTOTYPE NAME "street lamp 2" INHERIT "street lamp" MODEL "street lamp 2" /PROTOTYPE
The advantage here is that some objects will be able to inherit the properties of another object, and then simply override the ones that are different. Note that "street lamp 2" inherits street lamp but has a different model. The rule here is that an object can inherit the properties of an object that appeared above it in the file. Very simple but creates lots of opportunities.
I can spawn an object from this system at any time by just having the world send an "this object spawned" event, and the other systems will instantiate the appropriate object within their own ranks to match it.
My interpretation of the factory pattern is quite literal; I have an actual object being the factory, and this object creates the prototypes based on the data in a file, such as the one above. Each prototype knows how to instantiate an object with those properties.
The factory knows how to spawn only one class of object, so for each type of entity I have a different factory object.
Next weeks objective: Have characters spawning from a factory, and moving around the world, represented by a piece of debug geometry.