Just got rid of redundant code and got rid of a few warnings
This commit is contained in:
@@ -4,15 +4,12 @@ import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.Input;
|
||||
import com.badlogic.gdx.graphics.OrthographicCamera;
|
||||
import com.badlogic.gdx.graphics.g2d.Animation;
|
||||
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
|
||||
import com.mygdx.game.Restrictions;
|
||||
|
||||
public class InputController implements Restrictions {
|
||||
|
||||
private OrthographicCamera cam;
|
||||
private Player player;
|
||||
private Animation<TextureAtlas.AtlasRegion> animation;
|
||||
float pressTime, unpressTime;
|
||||
int i = 0;
|
||||
|
||||
public InputController(OrthographicCamera cam, Player player) {
|
||||
|
||||
@@ -8,7 +8,7 @@ import com.badlogic.gdx.utils.Array;
|
||||
import com.mygdx.game.Restrictions;
|
||||
|
||||
public class Player implements Restrictions {
|
||||
private int x,y = 0;
|
||||
private int x,y;
|
||||
private String spriteName;
|
||||
private TextureAtlas textureAtlas;
|
||||
private Animation<TextureAtlas.AtlasRegion> animation;
|
||||
@@ -43,18 +43,10 @@ public class Player implements Restrictions {
|
||||
return x;
|
||||
}
|
||||
|
||||
public void setX(int x) {
|
||||
this.x = x;
|
||||
}
|
||||
|
||||
public int getY() {
|
||||
return y;
|
||||
}
|
||||
|
||||
public void setY(int y) {
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
public void addX(int x){
|
||||
this.x += x;
|
||||
}
|
||||
@@ -67,10 +59,6 @@ public class Player implements Restrictions {
|
||||
return spriteName;
|
||||
}
|
||||
|
||||
public void setSpriteName(String tempSpriteName) {
|
||||
spriteName = tempSpriteName;
|
||||
}
|
||||
|
||||
TextureAtlas getTextureAtlas() {
|
||||
return textureAtlas;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,4 @@ public class Chunks {
|
||||
return blocks;
|
||||
}
|
||||
|
||||
public void setBlocks(HashMap<Pair<Integer, Integer>, Block> blocks) {
|
||||
this.blocks = blocks;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import static com.mygdx.game.Restrictions.CHUNK_SIZE;
|
||||
import static com.mygdx.game.Restrictions.SUPER_CHUNK_SIZE;
|
||||
|
||||
public class Superchunks {
|
||||
public static HashMap<Pair, Chunks> overworld = new HashMap<>();
|
||||
public static HashMap<Pair<Integer,Integer>, Chunks> overworld = new HashMap<>();
|
||||
|
||||
private Superchunks() {}
|
||||
|
||||
|
||||
@@ -24,7 +24,6 @@ public class WorldRenderer implements Restrictions {
|
||||
inputController = new InputController(this.cam, this.player);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void drawWorld(Batch batch) {
|
||||
for (Pair<Integer, Integer> worldpair: Superchunks.overworld.keySet()) {
|
||||
Chunks chunks = Superchunks.overworld.get(worldpair);
|
||||
|
||||
@@ -20,36 +20,20 @@ public class Main extends ApplicationAdapter {
|
||||
private SpriteBatch batch;
|
||||
private WorldRenderer worldRenderer;
|
||||
private GUI gui;
|
||||
private Mouse mouse;
|
||||
private OrthographicCamera cam;
|
||||
private Stage stage;
|
||||
private Table table;
|
||||
private Label label;
|
||||
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
|
||||
private Player player;
|
||||
|
||||
|
||||
@Override
|
||||
public void create () {
|
||||
Gdx.graphics.setWindowedMode(1024,576);
|
||||
cam = new OrthographicCamera(VIEWPORT_WIDTH,VIEWPORT_HEIGHT);
|
||||
|
||||
//
|
||||
stage = new Stage();
|
||||
Gdx.input.setInputProcessor(stage);
|
||||
|
||||
table = new Table();
|
||||
table.add(label);
|
||||
table.setFillParent(true);
|
||||
stage.addActor(table);
|
||||
|
||||
table.setDebug(true);
|
||||
|
||||
OrthographicCamera cam = new OrthographicCamera(VIEWPORT_WIDTH, VIEWPORT_HEIGHT);
|
||||
|
||||
drawGUI();
|
||||
|
||||
//Starting location of the player
|
||||
player = new Player(0,0, cam);
|
||||
Player player = new Player(0, 0, cam);
|
||||
|
||||
cam.translate((float) TILE_SIZE / 2, (float) TILE_SIZE / 2);
|
||||
cam.zoom = 25f;
|
||||
@@ -57,12 +41,25 @@ public class Main extends ApplicationAdapter {
|
||||
Superchunks.generateWithPlayer(player);
|
||||
|
||||
|
||||
mouse = new Mouse(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
|
||||
public void render () {
|
||||
Gdx.gl.glClear(GL30.GL_COLOR_BUFFER_BIT);
|
||||
|
||||
Reference in New Issue
Block a user