From c164daed53574babb26796b05682432709e2c5c1 Mon Sep 17 00:00:00 2001 From: mithe24 Date: Wed, 7 May 2025 17:11:58 +0200 Subject: 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. --- pacman/view/src/main/java/com/gr15/pacman/view/GameView.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'pacman/view/src/main/java') diff --git a/pacman/view/src/main/java/com/gr15/pacman/view/GameView.java b/pacman/view/src/main/java/com/gr15/pacman/view/GameView.java index 62617d6..d56a1e1 100644 --- a/pacman/view/src/main/java/com/gr15/pacman/view/GameView.java +++ b/pacman/view/src/main/java/com/gr15/pacman/view/GameView.java @@ -1,6 +1,7 @@ package com.gr15.pacman.view; import java.util.HashMap; +import java.util.List; import java.util.Map; import com.gr15.pacman.model.GameState; @@ -83,7 +84,8 @@ public class GameView - 0.5) * 16 * scaleY); pacmanSprite.render(gc); - gameState.getEntities().forEach((pos, entity) -> { + List entities = gameState.getEntities(); + for (Entity entity : entities) { Image texture = entityTextures.get(entity); if (texture != null) { gc.drawImage(texture, @@ -92,7 +94,7 @@ public class GameView texture.getWidth() * scaleX, texture.getHeight() * scaleY); } - }); + } gameState.getItems().forEach((pos, item) -> { Image texture = itemTextures.get(item); -- cgit v1.2.3-70-g09d2