From 1e5d36d12c4bf5100211da9ead8f74ab425378cd Mon Sep 17 00:00:00 2001 From: fdai7910 Date: Sat, 3 Feb 2024 20:21:57 +0100 Subject: [PATCH] added reference from Cell to Map --- src/main/java/pacmanGame/Cell.java | 4 +++- src/main/java/pacmanGame/Map.java | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/pacmanGame/Cell.java b/src/main/java/pacmanGame/Cell.java index f01761e..46c71f2 100644 --- a/src/main/java/pacmanGame/Cell.java +++ b/src/main/java/pacmanGame/Cell.java @@ -3,10 +3,12 @@ package pacmanGame; public class Cell { public Vector2 pos; public String type; + public final Map map; - public Cell(Vector2 pos, String type) { + public Cell(Vector2 pos, String type, Map map) { this.pos = pos; this.type = type; + this.map = map; } public void triggerDot() { diff --git a/src/main/java/pacmanGame/Map.java b/src/main/java/pacmanGame/Map.java index ce72d36..40ab6aa 100644 --- a/src/main/java/pacmanGame/Map.java +++ b/src/main/java/pacmanGame/Map.java @@ -76,7 +76,7 @@ public class Map { String cellType = mapTypes.get(String.valueOf(cellChar)); - cells[x][y] = new Cell(cellPos, cellType); + cells[x][y] = new Cell(cellPos, cellType, this); if(cellChar == playerSpawnChar) { playerSpawn = cellPos.Clone();