From 43e1d20f50a137fa629437ab095769b84b2a6467 Mon Sep 17 00:00:00 2001 From: DaanVanYperen Date: Sat, 31 Jan 2015 00:06:33 +0100 Subject: [PATCH 1/4] Upgrade to LibGDX 1.5.3, Artemis-ODB 0.8.2-SNAPSHOT --- README.md | 2 +- build.gradle | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index b23374d..8759430 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ into a library later, no guarantees. ;) ### Library Versions -LibGDX 1.5.0 and Artemis-ODB 0.8.1 +LibGDX 1.5.3 and Artemis-ODB 0.8.2-SNAPSHOT (LibGDX version can be changed in /build.gradle) Tested for desktop:dist and html:dist targets. Others targets might function too. ;) diff --git a/build.gradle b/build.gradle index a7967b3..1fbce3c 100644 --- a/build.gradle +++ b/build.gradle @@ -21,8 +21,8 @@ allprojects { ext { appName = 'GameTemplate' - gdxVersion = '1.5.0' - artemisVersion = '0.8.1' + gdxVersion = '1.5.3' + artemisVersion = '0.8.2-SNAPSHOT' roboVMVersion = '0.0.11' } From 123063bbd96a878f6560b7eb8f7f0022a8368894 Mon Sep 17 00:00:00 2001 From: DaanVanYperen Date: Sat, 31 Jan 2015 00:49:52 +0100 Subject: [PATCH 2/4] Add support for artemis-odb annotation processor. --- build.gradle | 17 +++++++++-- .../game/manager/EntityFactorySystem.java | 19 +++++------- .../game/manager/factory/DefaultEntity.java | 29 +++++++++++++++++++ 3 files changed, 51 insertions(+), 14 deletions(-) create mode 100644 core/src/net/mostlyoriginal/game/manager/factory/DefaultEntity.java diff --git a/build.gradle b/build.gradle index 1fbce3c..4272ebe 100644 --- a/build.gradle +++ b/build.gradle @@ -7,9 +7,17 @@ buildscript { } dependencies { classpath 'de.richsource.gradle.plugins:gwt-gradle-plugin:0.3' -// classpath 'com.android.tools.build:gradle:0.9+' -// classpath 'com.github.jtakakura:gradle-robovm-plugin:0.0.7' classpath "net.onedaybeard.artemis:artemis-odb-gradle-plugin:0.7.1" + + // introduces support for provided scope. + classpath 'com.netflix.nebula:gradle-extra-configurations-plugin:1.12.+' + + // replace with the current version of the Android plugin + // classpath 'com.android.tools.build:gradle:0.14.4' + // the latest version of the android-apt plugin + // classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4' + + // classpath 'com.github.jtakakura:gradle-robovm-plugin:0.0.7' } } @@ -102,6 +110,8 @@ project(":html") { project(":core") { apply plugin: "java" + apply plugin: 'provided-base' + sourceCompatibility = "1.7" targetCompatibility = "1.7" @@ -110,6 +120,9 @@ project(":core") { // Support for artemis-odb compile "net.onedaybeard.artemis:artemis-odb:$artemisVersion" + + // Artemis-odb annotation processor (see https://github.com/junkdog/artemis-odb/wiki/EntityFactory) + provided "net.onedaybeard.artemis:artemis-odb-processor:$artemisVersion" } } diff --git a/core/src/net/mostlyoriginal/game/manager/EntityFactorySystem.java b/core/src/net/mostlyoriginal/game/manager/EntityFactorySystem.java index 6fe9956..6e26ad5 100644 --- a/core/src/net/mostlyoriginal/game/manager/EntityFactorySystem.java +++ b/core/src/net/mostlyoriginal/game/manager/EntityFactorySystem.java @@ -8,12 +8,10 @@ import com.badlogic.gdx.graphics.g2d.TextureRegion; import com.badlogic.gdx.maps.MapProperties; import com.badlogic.gdx.math.MathUtils; -import net.mostlyoriginal.api.component.basic.Angle; import net.mostlyoriginal.api.component.basic.Bounds; import net.mostlyoriginal.api.component.basic.Pos; import net.mostlyoriginal.api.component.camera.Camera; import net.mostlyoriginal.api.component.graphics.Anim; -import net.mostlyoriginal.api.component.map.MapSolid; import net.mostlyoriginal.api.component.map.MapWallSensor; import net.mostlyoriginal.api.component.physics.*; import net.mostlyoriginal.api.component.script.Schedule; @@ -22,9 +20,10 @@ import net.mostlyoriginal.api.utils.SafeEntityReference; import net.mostlyoriginal.api.utils.TagEntityReference; import net.mostlyoriginal.game.MainScreen; -import net.mostlyoriginal.game.component.agent.Slumberer; import net.mostlyoriginal.game.component.agent.PlayerControlled; +import net.mostlyoriginal.game.component.agent.Slumberer; import net.mostlyoriginal.game.component.interact.Pluckable; +import net.mostlyoriginal.game.manager.factory.DefaultEntity; /** * Game specific entity factory. @@ -60,7 +59,7 @@ public Entity createEntity(String entity, int cx, int cy, MapProperties properti private Entity createSlumberer(int cx, int cy) { Entity slumberer = defaultEntity(cx, cy, "slumberer-idle").add(new Slumberer()).getEntity(); - slumberer.getComponent(Anim.class).layer = -2; + //slumberer.getComponent(Anim.class).layer = -2; Anim eyeAnim = new Anim("slumberer-eye", -3); eyeAnim.loop = false; @@ -155,15 +154,11 @@ private Bounds createCameraBounds() { ); } + + DefaultEntity defaultEntity; + private EntityEdit defaultEntity(int cx, int cy, String startingAnim) { - return world.createEntity().edit() - .add(new Pos(cx, cy)) - .add(new Angle()) - .add(new Bounds(0, 0, 25, 16)) - .add(new Anim(startingAnim)) - .add(new MapSolid()) - .add(new Physics()) - .add(new Gravity()); + return defaultEntity.pos(cx,cy).bounds(0,0,25,16).anim(startingAnim).create().edit(); } } diff --git a/core/src/net/mostlyoriginal/game/manager/factory/DefaultEntity.java b/core/src/net/mostlyoriginal/game/manager/factory/DefaultEntity.java new file mode 100644 index 0000000..5f71820 --- /dev/null +++ b/core/src/net/mostlyoriginal/game/manager/factory/DefaultEntity.java @@ -0,0 +1,29 @@ +package net.mostlyoriginal.game.manager.factory; + +import com.artemis.EntityFactory; +import com.artemis.annotations.Bind; +import net.mostlyoriginal.api.component.basic.Angle; +import net.mostlyoriginal.api.component.basic.Bounds; +import net.mostlyoriginal.api.component.basic.Pos; +import net.mostlyoriginal.api.component.graphics.Anim; +import net.mostlyoriginal.api.component.map.MapSolid; +import net.mostlyoriginal.api.component.physics.Gravity; +import net.mostlyoriginal.api.component.physics.Physics; + +/** + * Example entity factory + * + * To test Artemis-ODB's Annotation Processor. + * + * @author Daan van Yperen + */ +@Bind({Pos.class, Angle.class, Bounds.class, Anim.class, MapSolid.class, Physics.class, Gravity.class}) +public interface DefaultEntity extends EntityFactory { + + // By convention, method name is mapped to class with same name. + DefaultEntity pos(float x, float y); + + DefaultEntity bounds(int minx, int miny, int maxx, int maxy); + + DefaultEntity anim(String id); +} From dcac3597185486c55cab5427cd74b891718e1a21 Mon Sep 17 00:00:00 2001 From: DaanVanYperen Date: Tue, 10 Feb 2015 20:21:47 +0100 Subject: [PATCH 3/4] Upgrade to Artemis-ODB 0.9! --- build.gradle | 2 +- .../mostlyoriginal/api/system/render/AnimRenderSystem.java | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/build.gradle b/build.gradle index 4272ebe..4862315 100644 --- a/build.gradle +++ b/build.gradle @@ -30,7 +30,7 @@ allprojects { ext { appName = 'GameTemplate' gdxVersion = '1.5.3' - artemisVersion = '0.8.2-SNAPSHOT' + artemisVersion = '0.9.0' roboVMVersion = '0.0.11' } diff --git a/core/src/net/mostlyoriginal/api/system/render/AnimRenderSystem.java b/core/src/net/mostlyoriginal/api/system/render/AnimRenderSystem.java index c3cd8d8..256d8b7 100644 --- a/core/src/net/mostlyoriginal/api/system/render/AnimRenderSystem.java +++ b/core/src/net/mostlyoriginal/api/system/render/AnimRenderSystem.java @@ -10,6 +10,7 @@ import com.artemis.EntitySystem; import com.artemis.annotations.Wire; import com.artemis.utils.ImmutableBag; +import com.artemis.utils.IntBag; import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.graphics.g2d.TextureRegion; import net.mostlyoriginal.api.component.basic.Angle; @@ -72,8 +73,8 @@ protected void end() { batch.end(); } - @Override - protected void processEntities(ImmutableBag entities) { + @Override + protected void processEntities(IntBag intBag) { if (sortedDirty) { sortedDirty = false; From d901d8ae94dd58e40140848e950e21e7f2c57a14 Mon Sep 17 00:00:00 2001 From: DaanVanYperen Date: Tue, 10 Feb 2015 20:34:28 +0100 Subject: [PATCH 4/4] Update README.md @junkdog all seems well. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8759430..dccecd0 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ into a library later, no guarantees. ;) ### Library Versions -LibGDX 1.5.3 and Artemis-ODB 0.8.2-SNAPSHOT +LibGDX 1.5.3 and Artemis-ODB 0.9 (LibGDX version can be changed in /build.gradle) Tested for desktop:dist and html:dist targets. Others targets might function too. ;)