mirror of
https://github.com/inf112-v20/Fiasko.git
synced 2025-06-25 10:44:42 +02:00
Legger til en debug modus til spillet
This commit is contained in:
@ -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;
|
||||
}
|
||||
|
@ -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)));
|
||||
|
Reference in New Issue
Block a user