2016-11-27 15:15:41 (edited by chrisnorman7 2016-11-27 21:31:35)

Hi all,
In my quest to break my mindspace project into small chunks, I have just released the objects part of the code.

dumpible_objects provides you with an easy systems-agnostic way to represent your game objects pythonically, while making it dead easy to dump and load them to and from a simple json file.

To read the full docs (I don't want to repeat myself here), and clone or whatever, go to the Github page.

Here's a basic object though:

from dumpible_objects import BaseObject
class Weapon(BaseObject):
    def post_init(self):
        self.add_attribute('name', default='ordinalry-looking gun')  # The name of the weapon.
        self.add_attribute('shots', default=5)  # The number of shots left (or maybe blade strength?).
        self.add_attribute('#target')  # Preserves the target, assuming it is another instance of BaseObject.

That object would dump and reload with no problems, so you see you don't have to write boilerplate code for dumping the object, use multiple files or anything like that.

Hope this helps someone. There's a full test suite (11 tests), and the code is written specifically for Python 3.5, although it might work on earlier versions.

-----
I have code on GitHub

2016-11-30 09:02:48

Is this an entity component system?

2016-11-30 10:41:03

Hi,
I must confess I didn't know what an Entity component system was until I googled it, so I may be misunderstanding what you're asking.

It's simply another way to use objects, so you can subclass and what you like, same as creating normal classes.

From that perspective, yes you could use it to follow the entity component design principals (in so far as I understand them).

HTH, and sorry I'm possibly being vague.

-----
I have code on GitHub