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