From 3b4a3f89c453d4b9f61de2242d04c381564f380d Mon Sep 17 00:00:00 2001 From: fdai7753 Date: Wed, 7 Feb 2024 14:45:37 +0100 Subject: [PATCH 01/17] 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) { From 004abc7cf6f507ab66f8faacfac1e6bcf30c01fa Mon Sep 17 00:00:00 2001 From: fdai7753 Date: Wed, 7 Feb 2024 14:49:50 +0100 Subject: [PATCH 02/17] Addition of ghost spawn 1 on map --- src/main/java/pacmanGame/Map.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/pacmanGame/Map.java b/src/main/java/pacmanGame/Map.java index efca6cf..0d9beb8 100644 --- a/src/main/java/pacmanGame/Map.java +++ b/src/main/java/pacmanGame/Map.java @@ -53,7 +53,8 @@ public class Map { this.put(i+"", "empty"); } this.put("0", "empty"); - + this.put("1", "empty"); + }}; public GameManager gameManager; From 1a0812f5d5d93ddafce96a2ea100961cc962f3c1 Mon Sep 17 00:00:00 2001 From: fdai7753 Date: Wed, 7 Feb 2024 14:56:35 +0100 Subject: [PATCH 03/17] Addition of ghost spawn 2 on map --- src/main/java/pacmanGame/Map.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/pacmanGame/Map.java b/src/main/java/pacmanGame/Map.java index 0d9beb8..02f2abc 100644 --- a/src/main/java/pacmanGame/Map.java +++ b/src/main/java/pacmanGame/Map.java @@ -54,6 +54,7 @@ public class Map { } this.put("0", "empty"); this.put("1", "empty"); + this.put("2", "empty"); }}; public GameManager gameManager; From 694632982fd331f8d0ea6502c5ddba8e9ff7a988 Mon Sep 17 00:00:00 2001 From: fdai7753 Date: Wed, 7 Feb 2024 15:00:13 +0100 Subject: [PATCH 04/17] Addition of ghost spawn 3 on map --- src/main/java/pacmanGame/Map.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/pacmanGame/Map.java b/src/main/java/pacmanGame/Map.java index 02f2abc..b36f205 100644 --- a/src/main/java/pacmanGame/Map.java +++ b/src/main/java/pacmanGame/Map.java @@ -55,7 +55,7 @@ public class Map { this.put("0", "empty"); this.put("1", "empty"); this.put("2", "empty"); - + this.put("3", "empty"); }}; public GameManager gameManager; From fd806f977cd31afca52766c4bc21831d2d9be036 Mon Sep 17 00:00:00 2001 From: fdai7753 Date: Wed, 7 Feb 2024 15:09:09 +0100 Subject: [PATCH 05/17] Added ghost spawn 4 on Map grid --- src/main/java/pacmanGame/Map.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/pacmanGame/Map.java b/src/main/java/pacmanGame/Map.java index b36f205..4ac2306 100644 --- a/src/main/java/pacmanGame/Map.java +++ b/src/main/java/pacmanGame/Map.java @@ -19,7 +19,7 @@ public class Map { "wwwwwww.wweeeeeeeeeeww.wwwwwww", "wwwwwww.wwewwwwwwwweww.wwwwwww", "wwwwwww.wweweeeeeeweww.wwwwwww", - "eeeeeee.eeewe0ee2eweee.eeeeeee", + "eeeeeee.eeewe04e2eweee.eeeeeee", "wwwwwww.wwewe1ee3eweww.wwwwwww", "wwwwwww.wweweeeeeeweww.wwwwwww", "wwwwwww.wwewwwwwwwweww.wwwwwww", From da64069250b2d0b7727344a3af8d902c5c66044c Mon Sep 17 00:00:00 2001 From: fdai7753 Date: Wed, 7 Feb 2024 15:13:02 +0100 Subject: [PATCH 06/17] Added ghost spawn 5 on Map grid --- src/main/java/pacmanGame/Map.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/pacmanGame/Map.java b/src/main/java/pacmanGame/Map.java index 4ac2306..1e992e7 100644 --- a/src/main/java/pacmanGame/Map.java +++ b/src/main/java/pacmanGame/Map.java @@ -20,7 +20,7 @@ public class Map { "wwwwwww.wwewwwwwwwweww.wwwwwww", "wwwwwww.wweweeeeeeweww.wwwwwww", "eeeeeee.eeewe04e2eweee.eeeeeee", - "wwwwwww.wwewe1ee3eweww.wwwwwww", + "wwwwwww.wwewe15e3eweww.wwwwwww", "wwwwwww.wweweeeeeeweww.wwwwwww", "wwwwwww.wwewwwwwwwweww.wwwwwww", "wwwwwww.wweeeeeeeeeeww.wwwwwww", From 63ba36d6ef78d11b2315926ac27a72831afdfcb5 Mon Sep 17 00:00:00 2001 From: fdai7753 Date: Wed, 7 Feb 2024 15:17:04 +0100 Subject: [PATCH 07/17] Added ghost spawn 6 on Map grid --- src/main/java/pacmanGame/Map.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/pacmanGame/Map.java b/src/main/java/pacmanGame/Map.java index 1e992e7..bb361db 100644 --- a/src/main/java/pacmanGame/Map.java +++ b/src/main/java/pacmanGame/Map.java @@ -19,7 +19,7 @@ public class Map { "wwwwwww.wweeeeeeeeeeww.wwwwwww", "wwwwwww.wwewwwwwwwweww.wwwwwww", "wwwwwww.wweweeeeeeweww.wwwwwww", - "eeeeeee.eeewe04e2eweee.eeeeeee", + "eeeeeee.eeewe0462eweee.eeeeeee", "wwwwwww.wwewe15e3eweww.wwwwwww", "wwwwwww.wweweeeeeeweww.wwwwwww", "wwwwwww.wwewwwwwwwweww.wwwwwww", From 8a8f39e7baf79fddbc5b933414555b5f87098988 Mon Sep 17 00:00:00 2001 From: fdai7753 Date: Wed, 7 Feb 2024 15:21:54 +0100 Subject: [PATCH 08/17] Added ghost spawn 7 on Map grid --- src/main/java/pacmanGame/Map.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/pacmanGame/Map.java b/src/main/java/pacmanGame/Map.java index bb361db..7b17a82 100644 --- a/src/main/java/pacmanGame/Map.java +++ b/src/main/java/pacmanGame/Map.java @@ -20,7 +20,7 @@ public class Map { "wwwwwww.wwewwwwwwwweww.wwwwwww", "wwwwwww.wweweeeeeeweww.wwwwwww", "eeeeeee.eeewe0462eweee.eeeeeee", - "wwwwwww.wwewe15e3eweww.wwwwwww", + "wwwwwww.wwewe1573eweww.wwwwwww", "wwwwwww.wweweeeeeeweww.wwwwwww", "wwwwwww.wwewwwwwwwweww.wwwwwww", "wwwwwww.wweeeeeeeeeeww.wwwwwww", From ac5eb7b30952ef51600a820667228ca96457aaf3 Mon Sep 17 00:00:00 2001 From: fdai7753 Date: Wed, 7 Feb 2024 15:26:01 +0100 Subject: [PATCH 09/17] Addition of ghost spawn 4 on map --- src/main/java/pacmanGame/Map.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/pacmanGame/Map.java b/src/main/java/pacmanGame/Map.java index 7b17a82..d4458da 100644 --- a/src/main/java/pacmanGame/Map.java +++ b/src/main/java/pacmanGame/Map.java @@ -56,6 +56,7 @@ public class Map { this.put("1", "empty"); this.put("2", "empty"); this.put("3", "empty"); + this.put("4", "empty"); }}; public GameManager gameManager; From c891a12599e24f8ceec61946ce0b594444c2915f Mon Sep 17 00:00:00 2001 From: fdai7753 Date: Wed, 7 Feb 2024 15:29:56 +0100 Subject: [PATCH 10/17] Addition of ghost spawn 5 on map --- src/main/java/pacmanGame/Map.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/pacmanGame/Map.java b/src/main/java/pacmanGame/Map.java index d4458da..9db7f23 100644 --- a/src/main/java/pacmanGame/Map.java +++ b/src/main/java/pacmanGame/Map.java @@ -57,6 +57,7 @@ public class Map { this.put("2", "empty"); this.put("3", "empty"); this.put("4", "empty"); + this.put("5", "empty"); }}; public GameManager gameManager; From 928bd6d8e441c0294d0a3aa2b4bec4c5df6a3373 Mon Sep 17 00:00:00 2001 From: fdai7753 Date: Wed, 7 Feb 2024 15:31:40 +0100 Subject: [PATCH 11/17] Added ghost spawn 8 on Map grid --- src/main/java/pacmanGame/Map.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/pacmanGame/Map.java b/src/main/java/pacmanGame/Map.java index 9db7f23..a9e9ffe 100644 --- a/src/main/java/pacmanGame/Map.java +++ b/src/main/java/pacmanGame/Map.java @@ -19,7 +19,7 @@ public class Map { "wwwwwww.wweeeeeeeeeeww.wwwwwww", "wwwwwww.wwewwwwwwwweww.wwwwwww", "wwwwwww.wweweeeeeeweww.wwwwwww", - "eeeeeee.eeewe0462eweee.eeeeeee", + "eeeeeee.eeew80462eweee.eeeeeee", "wwwwwww.wwewe1573eweww.wwwwwww", "wwwwwww.wweweeeeeeweww.wwwwwww", "wwwwwww.wwewwwwwwwweww.wwwwwww", From 782d3d35013098edfb229d401d5e7ef46764576c Mon Sep 17 00:00:00 2001 From: fdai7753 Date: Wed, 7 Feb 2024 15:32:41 +0100 Subject: [PATCH 12/17] Added ghost spawn 9 on Map grid --- src/main/java/pacmanGame/Map.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/pacmanGame/Map.java b/src/main/java/pacmanGame/Map.java index a9e9ffe..d78dd82 100644 --- a/src/main/java/pacmanGame/Map.java +++ b/src/main/java/pacmanGame/Map.java @@ -19,7 +19,7 @@ public class Map { "wwwwwww.wweeeeeeeeeeww.wwwwwww", "wwwwwww.wwewwwwwwwweww.wwwwwww", "wwwwwww.wweweeeeeeweww.wwwwwww", - "eeeeeee.eeew80462eweee.eeeeeee", + "eeeeeee.eeew804629weee.eeeeeee", "wwwwwww.wwewe1573eweww.wwwwwww", "wwwwwww.wweweeeeeeweww.wwwwwww", "wwwwwww.wwewwwwwwwweww.wwwwwww", From 89fe8d19a7c1735726450a41e122631f323fbf31 Mon Sep 17 00:00:00 2001 From: fdai7753 Date: Wed, 7 Feb 2024 15:34:26 +0100 Subject: [PATCH 13/17] Addition of ghost spawn 6 on map --- src/main/java/pacmanGame/Map.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/pacmanGame/Map.java b/src/main/java/pacmanGame/Map.java index d78dd82..4ddb151 100644 --- a/src/main/java/pacmanGame/Map.java +++ b/src/main/java/pacmanGame/Map.java @@ -58,6 +58,7 @@ public class Map { this.put("3", "empty"); this.put("4", "empty"); this.put("5", "empty"); + this.put("6", "empty"); }}; public GameManager gameManager; From bc6532d754ba073f0cece97c29c1cce406547a8e Mon Sep 17 00:00:00 2001 From: fdai7753 Date: Wed, 7 Feb 2024 15:36:31 +0100 Subject: [PATCH 14/17] Addition of ghost spawn 7 on map --- src/main/java/pacmanGame/Map.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/pacmanGame/Map.java b/src/main/java/pacmanGame/Map.java index 4ddb151..ffd7424 100644 --- a/src/main/java/pacmanGame/Map.java +++ b/src/main/java/pacmanGame/Map.java @@ -59,6 +59,7 @@ public class Map { this.put("4", "empty"); this.put("5", "empty"); this.put("6", "empty"); + this.put("7", "empty"); }}; public GameManager gameManager; From 7dc1e5f67894dc3801d912733237c8d2c08996e2 Mon Sep 17 00:00:00 2001 From: fdai7753 Date: Wed, 7 Feb 2024 15:38:00 +0100 Subject: [PATCH 15/17] Addition of ghost spawn 8 on map --- src/main/java/pacmanGame/Map.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/pacmanGame/Map.java b/src/main/java/pacmanGame/Map.java index ffd7424..0464d50 100644 --- a/src/main/java/pacmanGame/Map.java +++ b/src/main/java/pacmanGame/Map.java @@ -60,6 +60,7 @@ public class Map { this.put("5", "empty"); this.put("6", "empty"); this.put("7", "empty"); + this.put("8", "empty"); }}; public GameManager gameManager; From 4b0345751dbc0e849a0676d08c941aaece695d45 Mon Sep 17 00:00:00 2001 From: fdai7753 Date: Wed, 7 Feb 2024 15:39:12 +0100 Subject: [PATCH 16/17] Addition of ghost spawn 9 on map --- src/main/java/pacmanGame/Map.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/pacmanGame/Map.java b/src/main/java/pacmanGame/Map.java index 0464d50..f48c937 100644 --- a/src/main/java/pacmanGame/Map.java +++ b/src/main/java/pacmanGame/Map.java @@ -61,6 +61,7 @@ public class Map { this.put("6", "empty"); this.put("7", "empty"); this.put("8", "empty"); + this.put("9", "empty"); }}; public GameManager gameManager; From 62ffa07a64f6c8f3a0a5dbbc55bf41101d24982d Mon Sep 17 00:00:00 2001 From: fdai7753 Date: Wed, 7 Feb 2024 15:44:17 +0100 Subject: [PATCH 17/17] refactoring: Removed redundant code --- src/main/java/pacmanGame/Map.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/main/java/pacmanGame/Map.java b/src/main/java/pacmanGame/Map.java index f48c937..77ebc6d 100644 --- a/src/main/java/pacmanGame/Map.java +++ b/src/main/java/pacmanGame/Map.java @@ -48,10 +48,6 @@ public class Map { this.put("s", "empty"); this.put(".", "dot"); this.put("w", "wall"); - - for(int i = 0; i < 10; i++) { - this.put(i+"", "empty"); - } this.put("0", "empty"); this.put("1", "empty"); this.put("2", "empty");