diff --git a/core/src/com/saltosion/gladiator/GladiatorBrawler.java b/core/src/com/saltosion/gladiator/GladiatorBrawler.java index a736e3a..ae62529 100644 --- a/core/src/com/saltosion/gladiator/GladiatorBrawler.java +++ b/core/src/com/saltosion/gladiator/GladiatorBrawler.java @@ -7,7 +7,7 @@ import com.badlogic.ashley.core.Family; import com.badlogic.gdx.ApplicationAdapter; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.graphics.g2d.Sprite; -import com.saltosion.gladiator.components.CPosition; +import com.saltosion.gladiator.components.CPhysics; import com.saltosion.gladiator.components.CRenderedObject; import com.saltosion.gladiator.systems.RenderingSystem; import com.saltosion.gladiator.util.GlobalStrings; @@ -27,7 +27,7 @@ public class GladiatorBrawler extends ApplicationAdapter { engine.addSystem(new RenderingSystem()); - engine.addEntityListener(Family.getFor(CRenderedObject.class, CPosition.class), + engine.addEntityListener(Family.getFor(CRenderedObject.class, CPhysics.class), new EntityListener() { @Override public void entityRemoved(Entity entity) { @@ -72,9 +72,8 @@ public class GladiatorBrawler extends ApplicationAdapter { renderedObject.addSequence("Idle", sequence); renderedObject.setCurrentSequence("Idle"); player.add(renderedObject); - player.add(new CPosition()); - player.getComponent(CPosition.class).x = 50; - player.getComponent(CPosition.class).y = 50; + player.add(new CPhysics()); + player.getComponent(CPhysics.class).position.set(50, 50); engine.addEntity(player); } diff --git a/core/src/com/saltosion/gladiator/components/CPhysics.java b/core/src/com/saltosion/gladiator/components/CPhysics.java new file mode 100644 index 0000000..b4934ee --- /dev/null +++ b/core/src/com/saltosion/gladiator/components/CPhysics.java @@ -0,0 +1,11 @@ +package com.saltosion.gladiator.components; + +import com.badlogic.ashley.core.Component; +import com.badlogic.gdx.math.Vector2; + +public class CPhysics extends Component { + + public Vector2 position = new Vector2(0, 0); + public Vector2 velocity = new Vector2(0, 0); + +} diff --git a/core/src/com/saltosion/gladiator/components/CPosition.java b/core/src/com/saltosion/gladiator/components/CPosition.java deleted file mode 100644 index 35f79bd..0000000 --- a/core/src/com/saltosion/gladiator/components/CPosition.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.saltosion.gladiator.components; - -import com.badlogic.ashley.core.Component; - -public class CPosition extends Component { - - public int x = 0; - public int y = 0; - -} diff --git a/core/src/com/saltosion/gladiator/systems/RenderingSystem.java b/core/src/com/saltosion/gladiator/systems/RenderingSystem.java index 37c5eae..40f4edc 100644 --- a/core/src/com/saltosion/gladiator/systems/RenderingSystem.java +++ b/core/src/com/saltosion/gladiator/systems/RenderingSystem.java @@ -12,13 +12,13 @@ import com.badlogic.gdx.graphics.OrthographicCamera; import com.badlogic.gdx.graphics.g2d.Sprite; import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.saltosion.gladiator.SpriteSequence; -import com.saltosion.gladiator.components.CPosition; +import com.saltosion.gladiator.components.CPhysics; import com.saltosion.gladiator.components.CRenderedObject; public class RenderingSystem extends EntitySystem { private ComponentMapper rom = ComponentMapper.getFor(CRenderedObject.class); - private ComponentMapper pm = ComponentMapper.getFor(CPosition.class); + private ComponentMapper pm = ComponentMapper.getFor(CPhysics.class); private ImmutableArray entities; private SpriteBatch batch; @@ -52,9 +52,9 @@ public class RenderingSystem extends EntitySystem { int currFrame = (int) Math.floor(renderedObject.getCurrentFrame()); Sprite currSprite = currSequence.getSprite(currFrame); - CPosition position = pm.get(entities.get(i)); + CPhysics physics = pm.get(entities.get(i)); - batch.draw(currSprite, position.x, position.y); + batch.draw(currSprite, physics.position.x, physics.position.y); float nextFrame = renderedObject.getCurrentFrame() + deltaTime*currSequence.getPlayspeed(); renderedObject.setCurrentFrame(nextFrame%currSequence.frameCount()); @@ -64,7 +64,7 @@ public class RenderingSystem extends EntitySystem { } public void updateEntities(Engine engine) { - entities = engine.getEntitiesFor(Family.getFor(CRenderedObject.class, CPosition.class)); + entities = engine.getEntitiesFor(Family.getFor(CRenderedObject.class, CPhysics.class)); } }