Skip to content

Commit

Permalink
Merge pull request #4 from DaanVanYperen/develop
Browse files Browse the repository at this point in the history
Upgrade to Artemis 0.9 and GDX 1.5.3
  • Loading branch information
DaanVanYperen committed Feb 10, 2015
2 parents 919ecf3 + d901d8a commit 4ed6b12
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 19 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.9
(LibGDX version can be changed in /build.gradle)

Tested for desktop:dist and html:dist targets. Others targets might function too. ;)
Expand Down
21 changes: 17 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
}

Expand All @@ -21,8 +29,8 @@ allprojects {

ext {
appName = 'GameTemplate'
gdxVersion = '1.5.0'
artemisVersion = '0.8.1'
gdxVersion = '1.5.3'
artemisVersion = '0.9.0'
roboVMVersion = '0.0.11'
}

Expand Down Expand Up @@ -102,6 +110,8 @@ project(":html") {

project(":core") {
apply plugin: "java"
apply plugin: 'provided-base'

sourceCompatibility = "1.7"
targetCompatibility = "1.7"

Expand All @@ -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"
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -72,8 +73,8 @@ protected void end() {
batch.end();
}

@Override
protected void processEntities(ImmutableBag<Entity> entities) {
@Override
protected void processEntities(IntBag intBag) {

if (sortedDirty) {
sortedDirty = false;
Expand Down
19 changes: 7 additions & 12 deletions core/src/net/mostlyoriginal/game/manager/EntityFactorySystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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.
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}

}
Original file line number Diff line number Diff line change
@@ -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<DefaultEntity> {

// 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);
}

0 comments on commit 4ed6b12

Please sign in to comment.