Added the Tween engine for easy interpolation

This commit is contained in:
2020-04-01 20:58:18 -06:00
parent 907691fbe7
commit cb3361630e
4 changed files with 28 additions and 29 deletions

View File

@@ -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();

View File

@@ -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

View File

@@ -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(){

BIN
libs/tween-engine-api.jar Normal file

Binary file not shown.