diff --git a/core/src/com/mygdx/game/Character/InputController.java b/core/src/com/mygdx/game/Character/InputController.java index 7a7ed08..7435628 100644 --- a/core/src/com/mygdx/game/Character/InputController.java +++ b/core/src/com/mygdx/game/Character/InputController.java @@ -49,6 +49,7 @@ public class InputController implements Restrictions { i = 0; directionAnimation("Up"); player.addY(MOVEMENT_SPEED); + //Tween.to(player,Tween.) cam.translate(0,MOVEMENT_SPEED); } cam.update(); diff --git a/core/src/com/mygdx/game/Main.java b/core/src/com/mygdx/game/Main.java index 97e8087..92b21b1 100644 --- a/core/src/com/mygdx/game/Main.java +++ b/core/src/com/mygdx/game/Main.java @@ -5,9 +5,7 @@ import com.badlogic.gdx.Gdx; import com.badlogic.gdx.graphics.GL30; import com.badlogic.gdx.graphics.OrthographicCamera; import com.badlogic.gdx.graphics.g2d.SpriteBatch; -import com.badlogic.gdx.scenes.scene2d.Stage; -import com.badlogic.gdx.scenes.scene2d.ui.Label; -import com.badlogic.gdx.scenes.scene2d.ui.Table; +import com.badlogic.gdx.utils.viewport.FitViewport; import com.mygdx.game.Character.Mouse; import com.mygdx.game.Character.Player; import com.mygdx.game.Dimension.Superchunks; @@ -20,7 +18,7 @@ public class Main extends ApplicationAdapter { private SpriteBatch batch; private WorldRenderer worldRenderer; private GUI gui; - private Label label; + private FitViewport fitViewport; float physicsUpdateSpeed = 1/60f; //how often you want to do a physics-update, in this case every 1/60th of a sec float timeSinceLastUpdate = 0f; //accumulator @@ -29,8 +27,7 @@ public class Main extends ApplicationAdapter { public void create () { Gdx.graphics.setWindowedMode(1024,576); OrthographicCamera cam = new OrthographicCamera(VIEWPORT_WIDTH, VIEWPORT_HEIGHT); - - drawGUI(); + fitViewport = new FitViewport(VIEWPORT_WIDTH,VIEWPORT_HEIGHT, cam); //Starting location of the player Player player = new Player(0, 0, cam); @@ -38,26 +35,14 @@ public class Main extends ApplicationAdapter { cam.translate((float) TILE_SIZE / 2, (float) TILE_SIZE / 2); cam.zoom = 25f; + Mouse mouse = new Mouse(player); + gui = new GUI(mouse,fitViewport); + Superchunks.generateWithPlayer(player); - Mouse mouse = new Mouse(player); worldRenderer = new WorldRenderer(player, mouse, cam); batch = new SpriteBatch(); - gui = new GUI(mouse, cam); - } - - public void drawGUI() { - // - Stage stage = new Stage(); - Gdx.input.setInputProcessor(stage); - - Table table = new Table(); - table.add(label); - table.setFillParent(true); - stage.addActor(table); - - table.setDebug(true); } @Override diff --git a/core/src/com/mygdx/game/UI/GUI.java b/core/src/com/mygdx/game/UI/GUI.java index 5f77f61..0f1ce4a 100644 --- a/core/src/com/mygdx/game/UI/GUI.java +++ b/core/src/com/mygdx/game/UI/GUI.java @@ -1,23 +1,36 @@ package com.mygdx.game.UI; -import com.badlogic.gdx.graphics.OrthographicCamera; +import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.g2d.BitmapFont; import com.badlogic.gdx.graphics.g2d.SpriteBatch; +import com.badlogic.gdx.scenes.scene2d.Stage; +import com.badlogic.gdx.scenes.scene2d.ui.Label; +import com.badlogic.gdx.utils.viewport.FitViewport; import com.mygdx.game.Character.Mouse; +import com.mygdx.game.Restrictions; -public class GUI { - private BitmapFont font = new BitmapFont(); +public class GUI implements Restrictions { + private Stage stage; + private Label label; private Mouse mouse; - private OrthographicCamera cam; + private BitmapFont font = new BitmapFont(); + private FitViewport fitViewport; - public GUI(Mouse mouse, OrthographicCamera cam) { - this.font = new BitmapFont(); + public GUI(Mouse mouse, FitViewport fitViewport) { this.mouse = mouse; - this.cam = cam; + this.fitViewport = fitViewport; + + stage = new Stage(fitViewport); + Gdx.input.setInputProcessor(stage); + label = new Label("Hello",new Label.LabelStyle(font,new Color(Color.WHITE))); + stage.addActor(label); } public void render(SpriteBatch batch){ - font.draw(batch, "x: "+ mouse.getTileX(cam) + "y: " + mouse.getTileY(cam),-10, 0); + stage.act(); + stage.draw(); + //font.draw(batch, "x: "+ mouse.getTileX(cam) + "y: " + mouse.getTileY(cam),-10, 0); } public void dispose(){ diff --git a/libs/tween-engine-api.jar b/libs/tween-engine-api.jar new file mode 100644 index 0000000..5004ce8 Binary files /dev/null and b/libs/tween-engine-api.jar differ