mirror of
https://github.com/inf112-v20/Fiasko.git
synced 2025-03-03 16:49:45 +01:00
Legger til en debug modus til spillet
This commit is contained in:
parent
0d90e2047e
commit
a63b0716b7
@ -25,6 +25,7 @@ public class GameLauncher extends ApplicationAdapter implements InputProcessor {
|
|||||||
private OrthographicCamera camera;
|
private OrthographicCamera camera;
|
||||||
private SpriteBatch batch;
|
private SpriteBatch batch;
|
||||||
private IDrawableGame game;
|
private IDrawableGame game;
|
||||||
|
private IDrawableGame debugGame;
|
||||||
|
|
||||||
private Texture robotTexture;
|
private Texture robotTexture;
|
||||||
private Texture textureSheet;
|
private Texture textureSheet;
|
||||||
@ -36,6 +37,7 @@ public class GameLauncher extends ApplicationAdapter implements InputProcessor {
|
|||||||
private Vector2 lastTouch;
|
private Vector2 lastTouch;
|
||||||
private final int viewPortWidth = 12 * tileDimensions;
|
private final int viewPortWidth = 12 * tileDimensions;
|
||||||
private final int viewPortHeight = 12 * tileDimensions;
|
private final int viewPortHeight = 12 * tileDimensions;
|
||||||
|
private boolean debugging = false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void create() {
|
public void create() {
|
||||||
@ -43,7 +45,8 @@ public class GameLauncher extends ApplicationAdapter implements InputProcessor {
|
|||||||
robotTexture = new Texture(Gdx.files.internal("assets/Robot.png"));
|
robotTexture = new Texture(Gdx.files.internal("assets/Robot.png"));
|
||||||
textureSheet = new Texture(Gdx.files.internal("assets/tiles.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 = new OrthographicCamera();
|
||||||
camera.setToOrtho(false, viewPortWidth, viewPortHeight);
|
camera.setToOrtho(false, viewPortWidth, viewPortHeight);
|
||||||
camera.position.set(viewPortWidth/2f, viewPortHeight/2f, 0);
|
camera.position.set(viewPortWidth/2f, viewPortHeight/2f, 0);
|
||||||
@ -101,11 +104,18 @@ public class GameLauncher extends ApplicationAdapter implements InputProcessor {
|
|||||||
cameraZoom -= 0.1;
|
cameraZoom -= 0.1;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
case Input.Keys.MINUS:
|
case Input.Keys.MINUS:
|
||||||
if (Gdx.input.isKeyPressed(Input.Keys.CONTROL_LEFT)) {
|
if (Gdx.input.isKeyPressed(Input.Keys.CONTROL_LEFT)) {
|
||||||
cameraZoom += 0.1;
|
cameraZoom += 0.1;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
case Input.Keys.HOME:
|
||||||
|
IDrawableGame temp = game;
|
||||||
|
this.game = debugGame;
|
||||||
|
this.debugGame = temp;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,28 @@ import java.util.concurrent.TimeUnit;
|
|||||||
public class Game implements IDrawableGame {
|
public class Game implements IDrawableGame {
|
||||||
private Board gameBoard;
|
private Board gameBoard;
|
||||||
|
|
||||||
|
public Game(boolean debug) {
|
||||||
|
if (debug) {
|
||||||
|
initializeDebugMode();
|
||||||
|
} else {
|
||||||
|
initializeGame();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public Game() {
|
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 {
|
try {
|
||||||
List<Robot> robots = new ArrayList<>();
|
List<Robot> robots = new ArrayList<>();
|
||||||
robots.add(new Robot(RobotID.ROBOT_1, new Position(1, 1)));
|
robots.add(new Robot(RobotID.ROBOT_1, new Position(1, 1)));
|
||||||
|
33
src/main/resources/boards/all_tiles_test_board.txt
Normal file
33
src/main/resources/boards/all_tiles_test_board.txt
Normal file
@ -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
|
Loading…
x
Reference in New Issue
Block a user