summaryrefslogtreecommitdiff
path: root/pacman/controller/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--pacman/controller/src/main/java/com/gr15/pacman/controller/GameApp.java19
-rw-r--r--pacman/controller/src/main/resources/testGameState.json22
2 files changed, 32 insertions, 9 deletions
diff --git a/pacman/controller/src/main/java/com/gr15/pacman/controller/GameApp.java b/pacman/controller/src/main/java/com/gr15/pacman/controller/GameApp.java
index 1c8bc75..ffd4493 100644
--- a/pacman/controller/src/main/java/com/gr15/pacman/controller/GameApp.java
+++ b/pacman/controller/src/main/java/com/gr15/pacman/controller/GameApp.java
@@ -1,7 +1,9 @@
package com.gr15.pacman.controller;
+import java.io.InputStream;
+
import com.gr15.pacman.model.GameState;
-import com.gr15.pacman.model.JsonParser;
+import com.gr15.pacman.model.GameStateBuilder;
import com.gr15.pacman.view.GameView;
import javafx.application.Application;
@@ -23,14 +25,13 @@ public class GameApp
primaryStage.setResizable(false);
primaryStage.setFullScreen(true);
- try {
- gameState = JsonParser.getGameState("test");
- } catch (Exception e) {
- e.printStackTrace();
- throw new RuntimeException("Failed to load game state: " + e.getMessage());
- }
-
- gameView = new GameView(gameState, 8, 5);
+ InputStream inputStream = this.getClass()
+ .getResourceAsStream("/testGameState.json");
+ GameState gameState = GameStateBuilder.fromJson(inputStream);
+ inputStream.close();
+ int tileWidth = gameState.getBoard().getWidth();
+ int tileHeight = gameState.getBoard().getHeight();
+ gameView = new GameView(gameState,tileWidth, tileHeight);
primaryStage.setScene(gameView);
gameController = new GameController(gameState, gameView);
diff --git a/pacman/controller/src/main/resources/testGameState.json b/pacman/controller/src/main/resources/testGameState.json
new file mode 100644
index 0000000..48e333a
--- /dev/null
+++ b/pacman/controller/src/main/resources/testGameState.json
@@ -0,0 +1,22 @@
+{
+ "pacman": {
+ "x": 1,
+ "y": 1,
+ "speed": 3.0,
+ "radius": 1.0
+ },
+
+ "itmes": [],
+ "board": [
+ ["W","W","W","W","W","W","W","W","W"],
+ ["W","E","E","E","E","E","E","E","W"],
+ ["E","E","W","W","E","W","W","E","E"],
+ ["W","E","W","W","E","W","W","E","W"],
+ ["W","E","W","W","E","W","W","E","W"],
+ ["W","E","E","E","E","E","E","E","W"],
+ ["W","E","W","W","E","W","W","E","W"],
+ ["E","E","W","W","E","W","W","E","E"],
+ ["W","E","E","E","E","E","E","E","W"],
+ ["W","W","W","W","W","W","W","W","W"]
+ ]
+}