NOTE: This was a precursor project to the Artemis Entity System framework and is not related to it.
--------------------------------------------------
What I use for my games.
It's a container framework for your in-game entities, that are made up of components.
JAR:
http://gamadu.com/artemis/old/artemis.jar
Source:
http://gamadu.com/artemis/old/artemis-src.zip
Very raw right now, but very usable. I prefered simplicity over complexity, and that's what this system is, pure entity/component system, with rendering layering (16 hardcoded), etc.
The example is quite bad, but shows you how to create an example entity, set a rendering layer, initialize, and add to the manager.
The manager is the heart and brain of the whole thing, make sure you check out the public methods.
There aren't any components included, it's really up to you to provide them. Artemis is just a entity/component container. Although, sometime in the future I could provide generic components.
Any questions how do accomplish things, ask here. Component based systems require different thinking.
Currently missing: adding/removing component of an active entity.
Make sure to resolve component dependencies in initialize() of a component. Initialize should be called AFTER all components have been added to the entity. (this is not required, but preferred for performance reasons)
Use however you like.
Example of instantiating an entity:
Code:
Entity e = new Entity("heavyTank","Heavy Tank", "tanks");
e.setComponent(new Transform(100,100));
Bounds b = new Bounds(30); // radius
e.setComponent(b);
Sprite sprite = new Sprite("unit.png");
sprite.setLayer(5); // higher means rendered later
e.setComponent(sprite);
e.initialize();
EntityManager.getInstance().addEntity(e);
After adding all entities to the EntityManager, all you need to update and render the game world is this:
Code:
@Override
public void update(GameContainer container, StateBasedGame game, int delta) throws SlickException {
EntityManager.getInstance().update(container, game, delta);
}
@Override
public void render(GameContainer container, StateBasedGame game, Graphics g) throws SlickException {
EntityManager.getInstance().render(container, game, g);
}