Legger til en debug modus til spillet

This commit is contained in:
2020-02-27 16:44:06 +01:00
parent 0d90e2047e
commit a63b0716b7
3 changed files with 65 additions and 1 deletions

View File

@ -25,6 +25,7 @@ public class GameLauncher extends ApplicationAdapter implements InputProcessor {
private OrthographicCamera camera;
private SpriteBatch batch;
private IDrawableGame game;
private IDrawableGame debugGame;
private Texture robotTexture;
private Texture textureSheet;
@ -36,6 +37,7 @@ public class GameLauncher extends ApplicationAdapter implements InputProcessor {
private Vector2 lastTouch;
private final int viewPortWidth = 12 * tileDimensions;
private final int viewPortHeight = 12 * tileDimensions;
private boolean debugging = false;
@Override
public void create() {
@ -43,7 +45,8 @@ public class GameLauncher extends ApplicationAdapter implements InputProcessor {
robotTexture = new Texture(Gdx.files.internal("assets/Robot.png"));
textureSheet = new Texture(Gdx.files.internal("assets/tiles.png"));
game = new Game();
debugGame = new Game(true);
game = new Game(false);
camera = new OrthographicCamera();
camera.setToOrtho(false, viewPortWidth, viewPortHeight);
camera.position.set(viewPortWidth/2f, viewPortHeight/2f, 0);
@ -101,11 +104,18 @@ public class GameLauncher extends ApplicationAdapter implements InputProcessor {
cameraZoom -= 0.1;
return true;
}
break;
case Input.Keys.MINUS:
if (Gdx.input.isKeyPressed(Input.Keys.CONTROL_LEFT)) {
cameraZoom += 0.1;
return true;
}
break;
case Input.Keys.HOME:
IDrawableGame temp = game;
this.game = debugGame;
this.debugGame = temp;
return true;
}
return false;
}

View File

@ -19,7 +19,28 @@ import java.util.concurrent.TimeUnit;
public class Game implements IDrawableGame {
private Board gameBoard;
public Game(boolean debug) {
if (debug) {
initializeDebugMode();
} else {
initializeGame();
}
}
public Game() {
initializeGame();
}
private void initializeDebugMode() {
List<Robot> robots = new ArrayList<>();
try {
gameBoard = BoardLoaderUtil.loadBoard("boards/all_tiles_test_board.txt", robots);
} catch (IOException e) {
e.printStackTrace();
}
}
private void initializeGame() {
try {
List<Robot> robots = new ArrayList<>();
robots.add(new Robot(RobotID.ROBOT_1, new Position(1, 1)));