From 3b4a3f89c453d4b9f61de2242d04c381564f380d Mon Sep 17 00:00:00 2001 From: fdai7753 Date: Wed, 7 Feb 2024 14:45:37 +0100 Subject: [PATCH] Continuation of adding ghost spawns --- src/main/java/pacmanGame/Map.java | 47 +++++++++++++++---------------- 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/src/main/java/pacmanGame/Map.java b/src/main/java/pacmanGame/Map.java index 2379e89..efca6cf 100644 --- a/src/main/java/pacmanGame/Map.java +++ b/src/main/java/pacmanGame/Map.java @@ -52,6 +52,8 @@ public class Map { for(int i = 0; i < 10; i++) { this.put(i+"", "empty"); } + this.put("0", "empty"); + }}; public GameManager gameManager; @@ -72,31 +74,28 @@ public class Map { } public void GenerateMap(String[] mapData) { - - int sizeY = mapData.length; - int sizeX = mapData[0].length(); - - size = new Vector2(sizeX, sizeY); - - cells = new Cell[size.x][size.y]; - - for(int x = 0; x < size.x; x++) { - for(int y = 0; y < size.y; y++) { - Vector2 cellPos = new Vector2(x,y); + int sizeY = mapData.length; + int sizeX = mapData[0].length(); - char cellChar = mapData[size.y - 1 - y].charAt(x); - - String cellType = mapTypes.get(String.valueOf(cellChar)); - - cells[x][y] = new Cell(cellPos, cellType); - - //for(int i = 0; i < gameManager.ghosts.length; i++) - - if(cellChar == playerSpawnChar) { - playerSpawn = cellPos.Clone(); - } - } - } + size = new Vector2(sizeX, sizeY); + + cells = new Cell[size.x][size.y]; + + for(int x = 0; x < size.x; x++) { + for(int y = 0; y < size.y; y++) { + Vector2 cellPos = new Vector2(x,y); + + char cellChar = mapData[size.y - 1 - y].charAt(x); + + String cellType = mapTypes.get(String.valueOf(cellChar)); + + cells[x][y] = new Cell(cellPos, cellType); + + if(cellChar == playerSpawnChar) { + playerSpawn = cellPos.Clone(); + } + } + } } public Cell GetCell(Vector2 pos) {