diff options
| author | mithe24 <mithe24@student.sdu.dk> | 2025-05-07 17:11:58 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-05-07 17:11:58 +0200 |
| commit | c164daed53574babb26796b05682432709e2c5c1 (patch) | |
| tree | 50690b34f82847368be7c08c54b4489d4fea3e15 /pacman/controller/src/main/java/com | |
| parent | ec0f4221ecd71c0b18e8403daa58b66077ec4343 (diff) | |
| download | pacman-c164daed53574babb26796b05682432709e2c5c1.tar.gz pacman-c164daed53574babb26796b05682432709e2c5c1.zip | |
Feature/json parser (#18)
* chore(model/json-parser): Added maven dependency
* chore(model): Removed old test JSON file
* refactor(model/GameState): List better then map, entities should be able
to overlap
* feat(Pacman): Added GameState builder to initiate GameState with given
paramters.
Added a short example JSON-file, more key-value pairs needs to be added
as the game progresses.
Likewise the builder won't parse for any other key-value pair
automatically.
Diffstat (limited to 'pacman/controller/src/main/java/com')
| -rw-r--r-- | pacman/controller/src/main/java/com/gr15/pacman/controller/GameApp.java | 19 |
1 files changed, 10 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); |