Added the Tween engine for easy interpolation
This commit is contained in:
@@ -49,6 +49,7 @@ public class InputController implements Restrictions {
|
|||||||
i = 0;
|
i = 0;
|
||||||
directionAnimation("Up");
|
directionAnimation("Up");
|
||||||
player.addY(MOVEMENT_SPEED);
|
player.addY(MOVEMENT_SPEED);
|
||||||
|
//Tween.to(player,Tween.)
|
||||||
cam.translate(0,MOVEMENT_SPEED);
|
cam.translate(0,MOVEMENT_SPEED);
|
||||||
}
|
}
|
||||||
cam.update();
|
cam.update();
|
||||||
|
|||||||
@@ -5,9 +5,7 @@ import com.badlogic.gdx.Gdx;
|
|||||||
import com.badlogic.gdx.graphics.GL30;
|
import com.badlogic.gdx.graphics.GL30;
|
||||||
import com.badlogic.gdx.graphics.OrthographicCamera;
|
import com.badlogic.gdx.graphics.OrthographicCamera;
|
||||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
||||||
import com.badlogic.gdx.scenes.scene2d.Stage;
|
import com.badlogic.gdx.utils.viewport.FitViewport;
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Label;
|
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Table;
|
|
||||||
import com.mygdx.game.Character.Mouse;
|
import com.mygdx.game.Character.Mouse;
|
||||||
import com.mygdx.game.Character.Player;
|
import com.mygdx.game.Character.Player;
|
||||||
import com.mygdx.game.Dimension.Superchunks;
|
import com.mygdx.game.Dimension.Superchunks;
|
||||||
@@ -20,7 +18,7 @@ public class Main extends ApplicationAdapter {
|
|||||||
private SpriteBatch batch;
|
private SpriteBatch batch;
|
||||||
private WorldRenderer worldRenderer;
|
private WorldRenderer worldRenderer;
|
||||||
private GUI gui;
|
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 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
|
float timeSinceLastUpdate = 0f; //accumulator
|
||||||
|
|
||||||
@@ -29,8 +27,7 @@ public class Main extends ApplicationAdapter {
|
|||||||
public void create () {
|
public void create () {
|
||||||
Gdx.graphics.setWindowedMode(1024,576);
|
Gdx.graphics.setWindowedMode(1024,576);
|
||||||
OrthographicCamera cam = new OrthographicCamera(VIEWPORT_WIDTH, VIEWPORT_HEIGHT);
|
OrthographicCamera cam = new OrthographicCamera(VIEWPORT_WIDTH, VIEWPORT_HEIGHT);
|
||||||
|
fitViewport = new FitViewport(VIEWPORT_WIDTH,VIEWPORT_HEIGHT, cam);
|
||||||
drawGUI();
|
|
||||||
|
|
||||||
//Starting location of the player
|
//Starting location of the player
|
||||||
Player player = new Player(0, 0, cam);
|
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.translate((float) TILE_SIZE / 2, (float) TILE_SIZE / 2);
|
||||||
cam.zoom = 25f;
|
cam.zoom = 25f;
|
||||||
|
|
||||||
|
Mouse mouse = new Mouse(player);
|
||||||
|
gui = new GUI(mouse,fitViewport);
|
||||||
|
|
||||||
Superchunks.generateWithPlayer(player);
|
Superchunks.generateWithPlayer(player);
|
||||||
|
|
||||||
|
|
||||||
Mouse mouse = new Mouse(player);
|
|
||||||
worldRenderer = new WorldRenderer(player, mouse, cam);
|
worldRenderer = new WorldRenderer(player, mouse, cam);
|
||||||
batch = new SpriteBatch();
|
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
|
@Override
|
||||||
|
|||||||
@@ -1,23 +1,36 @@
|
|||||||
package com.mygdx.game.UI;
|
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.BitmapFont;
|
||||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
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.Character.Mouse;
|
||||||
|
import com.mygdx.game.Restrictions;
|
||||||
|
|
||||||
public class GUI {
|
public class GUI implements Restrictions {
|
||||||
private BitmapFont font = new BitmapFont();
|
private Stage stage;
|
||||||
|
private Label label;
|
||||||
private Mouse mouse;
|
private Mouse mouse;
|
||||||
private OrthographicCamera cam;
|
private BitmapFont font = new BitmapFont();
|
||||||
|
private FitViewport fitViewport;
|
||||||
|
|
||||||
public GUI(Mouse mouse, OrthographicCamera cam) {
|
public GUI(Mouse mouse, FitViewport fitViewport) {
|
||||||
this.font = new BitmapFont();
|
|
||||||
this.mouse = mouse;
|
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){
|
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(){
|
public void dispose(){
|
||||||
|
|||||||
BIN
libs/tween-engine-api.jar
Normal file
BIN
libs/tween-engine-api.jar
Normal file
Binary file not shown.
Reference in New Issue
Block a user