diff --git a/core/src/com/saltosion/gladiator/GladiatorBrawler.java b/core/src/com/saltosion/gladiator/GladiatorBrawler.java index fb6981a..a2e2cbc 100644 --- a/core/src/com/saltosion/gladiator/GladiatorBrawler.java +++ b/core/src/com/saltosion/gladiator/GladiatorBrawler.java @@ -13,6 +13,9 @@ import com.saltosion.gladiator.components.CPhysics; import com.saltosion.gladiator.components.CRenderedObject; import com.saltosion.gladiator.gui.ButtonNode; import com.saltosion.gladiator.gui.GUIManager; +import com.saltosion.gladiator.gui.GUINode; +import com.saltosion.gladiator.gui.TextNode; +import com.saltosion.gladiator.gui.TextProperty; import com.saltosion.gladiator.input.InputHandler; import com.saltosion.gladiator.listeners.CombatListener; import com.saltosion.gladiator.listeners.ai.DummyAI; @@ -202,6 +205,10 @@ public class GladiatorBrawler extends ApplicationAdapter { }; button.setPosition(0.12f, 0.5f); guiManager.getRootNode().addChild(button); + + TextNode text = new TextNode("test-text", "Test!"); + text.setPosition(0.01f, 0.99f); + guiManager.getRootNode().addChild(text); } @Override diff --git a/core/src/com/saltosion/gladiator/components/CAI.java b/core/src/com/saltosion/gladiator/components/CAI.java index fba0c75..f6ebfaa 100644 --- a/core/src/com/saltosion/gladiator/components/CAI.java +++ b/core/src/com/saltosion/gladiator/components/CAI.java @@ -3,10 +3,6 @@ package com.saltosion.gladiator.components; import com.badlogic.ashley.core.Component; import com.saltosion.gladiator.listeners.AIListener; -/** - * - * @author Jens "Jeasonfire" Pitkänen - */ public class CAI extends Component { private AIListener listener; diff --git a/core/src/com/saltosion/gladiator/gui/TextNode.java b/core/src/com/saltosion/gladiator/gui/TextNode.java new file mode 100644 index 0000000..d09e034 --- /dev/null +++ b/core/src/com/saltosion/gladiator/gui/TextNode.java @@ -0,0 +1,17 @@ +package com.saltosion.gladiator.gui; + +public class TextNode extends GUINode implements TextProperty { + + private String text; + + public TextNode(String ID, String text) { + super(ID); + this.text = text; + } + + @Override + public String getText() { + return text; + } + +} diff --git a/core/src/com/saltosion/gladiator/gui/TextProperty.java b/core/src/com/saltosion/gladiator/gui/TextProperty.java new file mode 100644 index 0000000..33f7269 --- /dev/null +++ b/core/src/com/saltosion/gladiator/gui/TextProperty.java @@ -0,0 +1,7 @@ +package com.saltosion.gladiator.gui; + +public interface TextProperty { + + public String getText(); + +} diff --git a/core/src/com/saltosion/gladiator/input/IRDebugToggle.java b/core/src/com/saltosion/gladiator/input/IRDebugToggle.java index 46ffccd..e4410c4 100644 --- a/core/src/com/saltosion/gladiator/input/IRDebugToggle.java +++ b/core/src/com/saltosion/gladiator/input/IRDebugToggle.java @@ -3,10 +3,6 @@ package com.saltosion.gladiator.input; import com.saltosion.gladiator.systems.RenderingSystem; import com.saltosion.gladiator.util.AppUtil; -/** - * - * @author Jens "Jeasonfire" Pitkänen - */ public class IRDebugToggle implements InputReceiver { @Override diff --git a/core/src/com/saltosion/gladiator/listeners/AIListener.java b/core/src/com/saltosion/gladiator/listeners/AIListener.java index d32975b..4942ea7 100644 --- a/core/src/com/saltosion/gladiator/listeners/AIListener.java +++ b/core/src/com/saltosion/gladiator/listeners/AIListener.java @@ -3,10 +3,6 @@ package com.saltosion.gladiator.listeners; import com.badlogic.ashley.core.Entity; import java.util.ArrayList; -/** - * - * @author Jens "Jeasonfire" Pitkänen - */ public interface AIListener { /** diff --git a/core/src/com/saltosion/gladiator/listeners/CollisionListener.java b/core/src/com/saltosion/gladiator/listeners/CollisionListener.java index ce747e9..930629e 100644 --- a/core/src/com/saltosion/gladiator/listeners/CollisionListener.java +++ b/core/src/com/saltosion/gladiator/listeners/CollisionListener.java @@ -3,21 +3,17 @@ package com.saltosion.gladiator.listeners; import com.badlogic.ashley.core.Entity; import com.saltosion.gladiator.util.Direction; -/** - * - * @author Jens "Jeasonfire" Pitkänen - */ public interface CollisionListener { - /** - * This method will be called when host collides with other - * - * @param side The side which host is colliding other with. Eg. if host is - * falling towards other, this argument will be CollisionSide.BOTTOM when - * the collision happens. - * @param host - * @param other - */ - public void collision(Direction side, Entity host, Entity other); + /** + * This method will be called when host collides with other + * + * @param side The side which host is colliding other with. Eg. if host is + * falling towards other, this argument will be CollisionSide.BOTTOM when + * the collision happens. + * @param host + * @param other + */ + public void collision(Direction side, Entity host, Entity other); } diff --git a/core/src/com/saltosion/gladiator/listeners/ai/DummyAI.java b/core/src/com/saltosion/gladiator/listeners/ai/DummyAI.java index 9ce8224..5f054d4 100644 --- a/core/src/com/saltosion/gladiator/listeners/ai/DummyAI.java +++ b/core/src/com/saltosion/gladiator/listeners/ai/DummyAI.java @@ -8,10 +8,6 @@ import com.saltosion.gladiator.listeners.AIListener; import com.saltosion.gladiator.util.Direction; import java.util.ArrayList; -/** - * - * @author Jens "Jeasonfire" Pitkänen - */ public class DummyAI implements AIListener { private static final ComponentMapper pm = ComponentMapper.getFor(CPhysics.class); diff --git a/core/src/com/saltosion/gladiator/systems/AISystem.java b/core/src/com/saltosion/gladiator/systems/AISystem.java index 1441b93..8cab3d7 100644 --- a/core/src/com/saltosion/gladiator/systems/AISystem.java +++ b/core/src/com/saltosion/gladiator/systems/AISystem.java @@ -11,10 +11,6 @@ import com.saltosion.gladiator.components.CCombat; import com.saltosion.gladiator.components.CPhysics; import java.util.ArrayList; -/** - * - * @author Jens "Jeasonfire" Pitkänen - */ public class AISystem extends EntitySystem { private static final ComponentMapper pm = ComponentMapper.getFor(CPhysics.class); diff --git a/core/src/com/saltosion/gladiator/systems/PhysicsSystem.java b/core/src/com/saltosion/gladiator/systems/PhysicsSystem.java index 2ad7812..113c48c 100644 --- a/core/src/com/saltosion/gladiator/systems/PhysicsSystem.java +++ b/core/src/com/saltosion/gladiator/systems/PhysicsSystem.java @@ -10,10 +10,6 @@ import com.saltosion.gladiator.components.CCombat; import com.saltosion.gladiator.components.CPhysics; import com.saltosion.gladiator.util.Direction; -/** - * - * @author Jens "Jeasonfire" Pitkänen - */ public class PhysicsSystem extends EntitySystem { private static final float MAX_VEL = 0.5f; diff --git a/core/src/com/saltosion/gladiator/systems/RenderingSystem.java b/core/src/com/saltosion/gladiator/systems/RenderingSystem.java index 1141105..ef65dae 100644 --- a/core/src/com/saltosion/gladiator/systems/RenderingSystem.java +++ b/core/src/com/saltosion/gladiator/systems/RenderingSystem.java @@ -21,8 +21,11 @@ import com.saltosion.gladiator.components.CPhysics; import com.saltosion.gladiator.components.CRenderedObject; import com.saltosion.gladiator.gui.GUINode; import com.saltosion.gladiator.gui.ImageNode; +import com.saltosion.gladiator.gui.TextNode; +import com.saltosion.gladiator.gui.TextProperty; import com.saltosion.gladiator.util.AppUtil; import com.saltosion.gladiator.util.Global; +import com.saltosion.gladiator.util.Log; import com.saltosion.gladiator.util.SpriteSequence; import java.util.ArrayList; import java.util.List; @@ -54,7 +57,7 @@ public class RenderingSystem extends EntitySystem { batch = new SpriteBatch(); font = new BitmapFont(Gdx.files.internal("fonts/roman.fnt")); - font.setUseIntegerPositions(true); + font.setUseIntegerPositions(false); debugRenderer = new ShapeRenderer(); @@ -77,20 +80,20 @@ public class RenderingSystem extends EntitySystem { CPhysics phys = pm.get(AppUtil.player); camera.position.set(phys.getPosition().x, phys.getPosition().y, 0); camera.update(); - fontCamera.position.set(phys.getPosition().x * Global.FONT_SCALE, phys.getPosition().y * Global.FONT_SCALE, 0); + fontCamera.position.set(camera.position.x * Global.FONT_SCALE, camera.position.y * Global.FONT_SCALE, 0); fontCamera.update(); Gdx.gl.glClearColor(0, 0, 0, 0); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); - batch.setProjectionMatrix(camera.combined); renderEntities(deltaTime); - renderGUI(Vector2.Zero); + renderGUI(new Vector2(0, 0)); renderDebug(camera); renderFont(fontCamera); } private void renderEntities(float deltaTime) { + batch.setProjectionMatrix(camera.combined); batch.begin(); for (int i = 0; i < entities.size(); i++) { CRenderedObject renderedObject = rom.get(entities.get(i)); @@ -114,6 +117,7 @@ public class RenderingSystem extends EntitySystem { } private void renderGUI(Vector2 rootPosition) { + batch.setProjectionMatrix(camera.combined); batch.begin(); renderGUINode(AppUtil.guiManager.getRootNode(), rootPosition); batch.end(); @@ -127,8 +131,14 @@ public class RenderingSystem extends EntitySystem { position.y * AppUtil.VPHEIGHT_CONST - s.getHeight() / 2 + camera.position.y); s.draw(batch); } + if (node instanceof TextNode) { + Log.info("X: " + position.x); + Log.info("Y: " + position.y); + drawString(((TextProperty) node).getText(), new Vector2(position.x * AppUtil.VPHEIGHT_CONST * aspectratio + camera.position.x, + position.y * AppUtil.VPHEIGHT_CONST + camera.position.y)); + } for (GUINode child : node.getChildren()) { - renderGUINode(child, position); + renderGUINode(child, new Vector2(position)); } } @@ -164,7 +174,7 @@ public class RenderingSystem extends EntitySystem { batch.setProjectionMatrix(fontCamera.combined); batch.begin(); for (TextObject obj : drawableText) { - font.draw(batch, obj.text, obj.position.x / Global.FONT_SCALE, obj.position.y / Global.FONT_SCALE); + font.draw(batch, obj.text, obj.position.x * Global.FONT_SCALE, obj.position.y * Global.FONT_SCALE); } drawableText.clear(); batch.end(); diff --git a/core/src/com/saltosion/gladiator/util/Direction.java b/core/src/com/saltosion/gladiator/util/Direction.java index f31ab32..54375d7 100644 --- a/core/src/com/saltosion/gladiator/util/Direction.java +++ b/core/src/com/saltosion/gladiator/util/Direction.java @@ -1,9 +1,5 @@ package com.saltosion.gladiator.util; -/** - * - * @author Jens "Jeasonfire" Pitkänen - */ public enum Direction { UP, DOWN, LEFT, RIGHT, CENTRE