From a63b0716b724590517d47a883300f9ed3dbebd15 Mon Sep 17 00:00:00 2001 From: EpicKnarvik97 Date: Thu, 27 Feb 2020 16:44:06 +0100 Subject: [PATCH] Legger til en debug modus til spillet --- .../inf112/fiasko/roborally/GameLauncher.java | 12 ++++++- .../inf112/fiasko/roborally/game/Game.java | 21 ++++++++++++ .../resources/boards/all_tiles_test_board.txt | 33 +++++++++++++++++++ 3 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 src/main/resources/boards/all_tiles_test_board.txt diff --git a/src/main/java/inf112/fiasko/roborally/GameLauncher.java b/src/main/java/inf112/fiasko/roborally/GameLauncher.java index a8eda29..baca17f 100644 --- a/src/main/java/inf112/fiasko/roborally/GameLauncher.java +++ b/src/main/java/inf112/fiasko/roborally/GameLauncher.java @@ -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; } diff --git a/src/main/java/inf112/fiasko/roborally/game/Game.java b/src/main/java/inf112/fiasko/roborally/game/Game.java index 153cabf..10c9f70 100644 --- a/src/main/java/inf112/fiasko/roborally/game/Game.java +++ b/src/main/java/inf112/fiasko/roborally/game/Game.java @@ -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 robots = new ArrayList<>(); + try { + gameBoard = BoardLoaderUtil.loadBoard("boards/all_tiles_test_board.txt", robots); + } catch (IOException e) { + e.printStackTrace(); + } + } + + private void initializeGame() { try { List robots = new ArrayList<>(); robots.add(new Robot(RobotID.ROBOT_1, new Position(1, 1))); diff --git a/src/main/resources/boards/all_tiles_test_board.txt b/src/main/resources/boards/all_tiles_test_board.txt new file mode 100644 index 0000000..b188481 --- /dev/null +++ b/src/main/resources/boards/all_tiles_test_board.txt @@ -0,0 +1,33 @@ +8 16 +01;1 01;3 01;5 01;7 02;1 02;3 02;5 02;7 +03;1 03;3 03;5 03;7 04;1 04;3 04;5 04;7 +05;1 05;3 05;5 05;7 06;1 06;3 06;5 06;7 +07;1 07;3 07;5 07;7 08;1 08;3 08;5 08;7 +09;1 09;3 09;5 09;7 10;1 10;3 10;5 10;7 +11;1 11;3 11;5 11;7 12;1 12;3 12;5 12;7 +13;1 13;3 13;5 13;7 14;1 14;3 14;5 14;7 +15;1 15;3 15;5 15;7 16;1 16;3 16;5 16;7 +17;1 17;3 17;5 17;7 18;1 18;3 18;5 18;7 +19;1 19;3 19;5 19;7 20;1 20;3 20;5 20;7 +21;1 21;3 21;5 21;7 22;1 22;3 22;5 22;7 +23;1 23;3 23;5 23;7 24;1 24;3 24;5 24;7 +25;1 25;3 25;5 25;7 26;1 26;3 26;5 26;7 +27;1 27;3 27;5 27;7 28;1 28;3 28;5 28;7 +29;1 29;3 29;5 29;7 30;1 30;3 30;5 30;7 +31;1 31;3 31;5 31;7 01;1 01;1 01;1 01;1 +0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 \ No newline at end of file