How to combine artemis-odb + Glenn Fiedler game loop

775 views Asked by At

I want to use artemis (https://github.com/junkdog/artemis-odb) for my game.

Lately I read about Glenn Fiedler's game loop: http://gafferongames.com/game-physics/fix-your-timestep/

So the mentioned game loop has two parts where artemis world.process(); would take place. The integrate part and the render part.

Any ideas how I could accomplish something like this with artemis.

while(!quit) {
    .....
    while (accumulator >= dt) {
       world.process("only EntitySystems of group1 or with Components X (INTEGRATE STUFF)");
       ....
    }
    ....
    world.process("only EntitySystems of group2 or with Components Y (RENDER STUFF)");
}

Does artemis support this kind of gameloop?

The only solution which comes to my mind right now is:

Set a global static flag which indicates whether its integrate or render process and then exit all EntitySystem.process(Entity e) methods when the wrong flag is set. Like this:

@Override
protected void process(Entity e) {
    if(GLOBAL.RENDER_TIME) {
        return; // exit cause, this entity should only be processed when it is INTEGRATE TIME
    }   
}

Problem with this is that there are iteration over a lot of entities which are not required since the entities do not process anything.

I was thinking about having 2 Worlds but I don't think I can easily share same Component instances between Worlds, especially when they are pooled objects.

Any idea how to combine artemis-odb + Glenn Fiedler game loop?

EDIT: Just figured out I can use setEnabled() to disable and enable EntitySystems. This will do it for now.

1

There are 1 answers

0
TomGrill Games On BEST ANSWER