libgdx / ashley

A Java entity system inspired by Ash & Artemis.
Apache License 2.0
875 stars 144 forks source link

Update libGDX to 1.10.0 and Java Source to 1.7 and create utility functions for iterating systems #299

Closed undefinedhuman closed 3 years ago

undefinedhuman commented 3 years ago

Updating to the newest libGDX version, through the update to Gradle 4.3 java source compatibility 1.6 is no longer supported, so updated to version 1.7 (which is also deprecated and should be updated to 1.8 in the near future)

Fix libGDX capitalization in the readme, as the official libGDX repo did it

Created small utility functions in the iterating systems to enable the efficient usage of iterating systems for render systems and such:

Example Implementation of a Render System:

public class RenderSystem extends IteratingSystem {

    private SpriteBatch batch;
    private OrthographicCamera camera;

    private ComponentMapper<PositionComponent> pm = ComponentMapper.getFor(PositionComponent.class);
    private ComponentMapper<VisualComponent> vm = ComponentMapper.getFor(VisualComponent.class);

    public RenderSystem (OrthographicCamera camera) {
        super(Family.all(PositionComponent.class, VisualComponent.class).get());
        batch = new SpriteBatch();
        this.camera = camera;
    }

    @Override
    public void startProcessing() {
        camera.update();

        batch.setProjectionMatrix(camera.combined);
        batch.begin();
    }

    @Override
    protected void processEntity(Entity entity, float deltaTime) {
        PositionComponent position = pm.get(entity);
        VisualComponent visual = vm.get(entity);

        batch.draw(visual.region, position.x, position.y);
    }

    @Override
    public void endProcessing() {
        batch.end();
    }
}
undefinedhuman commented 3 years ago

If those unit tests are not sufficient, I can change them and include more

MrStahlfelge commented 3 years ago

When we update to gdx 1.10.0, next ashley version can't be used by someone depending on an older version. We should only raise this when needed because of incompatibilities. Is this the case here?

undefinedhuman commented 3 years ago

No, that was actually not the case, but the increase of the Java source version was necessary due to incompatibility with the Gradle version currently in use. Should I lower the libGDX version again?

MrStahlfelge commented 3 years ago

In my opinion it should be lowered to a reasonable version, 1.9.8 or 1.9.10 are good bets.

undefinedhuman commented 3 years ago

I tested, 1.9.8, 1.9.9, and 1.9.10, which one would you recommend?

MrStahlfelge commented 3 years ago

When 1.9.8 works, use it :)