Hi guys!
It’s been quite a while since I’ve posted but I’ve been lurking regularly as I finished up my first year of grad school. The big news now is that I’ve released a significant update to my entity-component framework: http://entreri.lhkbob.com and https://bitbucket.org/mludwig/entreri. I posted previously about an earlier version of Entreri: http://www.java-gaming.org/index.php?topic=24962.0
You guys gave me some good feedback, mostly about scariness of strict component definition rules I had imposed. After some significant revisions, I’ve updated it to allow you to define your component types as Java bean interfaces, and then an annotation processor to generate the implementation that uses a mapped-object model for performance.
As an example, I could define two components as follows:
public interface Location extends Component {
public float getX();
public Location setX(float v); // automatically returns this component
public float getY();
public Location setY(float v); // ""
}
public interface Health extends Component {
public int getHealth();
public Health setHealth(int v);
}
Then using these components would look along these lines:
EntitySystem system = EntitySystem.Factory.create();
Entity player = system.addEntity();
player.add(Location.class).setX(0).setY(0);
player.add(Health.class).setHealth(250);
// .. later in your main loop ..
// this shows how to iterate over all entities with a single component type,
// and it uses a flyweight instance for faster iteration over the underlying data
ComponentIterator checkForDead = system.fastIterator();
Health flyweightInstance = checkForDead.addRequired(Health.class);
while(checkForDead.next()) {
if (flyweightInstance.getHealth() <= 0) {
system.removeEntity(flyweightInstance.getEntity());
}
}
Other new features include a parent-child hierarchy model that makes it easy to have one entity for the player, and another entity for its weapon and link them so that deleting the player entity will automatically delete the weapon. Another is a multi-threaded job/task API that tries to make simple parallelization easy to do without much thought, such as splitting the rendering and physics tasks onto separate threads with minimal synchronization.
I’d love to hear more feedback, and hopefully get people who have had experience with other libraries such as Artemis, or Ash, to give it a comparison.
Thanks!
Michael