From 4238e60c49fd419c13da23d92b92dc56980eb99b Mon Sep 17 00:00:00 2001 From: 0NATE4 Date: Sat, 14 Sep 2024 10:51:31 +1000 Subject: [PATCH 01/19] Added base for maze. including grid, grid cells, and types of cells --- .../components/minigames/maze/MazeGame.java | 4 +++ .../minigames/maze/mazegrid/MazeCell.java | 26 +++++++++++++++++++ .../minigames/maze/mazegrid/MazeGrid.java | 22 ++++++++++++++++ .../minigames/maze/mazegrid/NotWall.java | 7 +++++ .../minigames/maze/mazegrid/Wall.java | 7 +++++ 5 files changed, 66 insertions(+) create mode 100644 source/core/src/main/com/csse3200/game/components/minigames/maze/MazeGame.java create mode 100644 source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/MazeCell.java create mode 100644 source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/MazeGrid.java create mode 100644 source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/NotWall.java create mode 100644 source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/Wall.java diff --git a/source/core/src/main/com/csse3200/game/components/minigames/maze/MazeGame.java b/source/core/src/main/com/csse3200/game/components/minigames/maze/MazeGame.java new file mode 100644 index 000000000..61b161110 --- /dev/null +++ b/source/core/src/main/com/csse3200/game/components/minigames/maze/MazeGame.java @@ -0,0 +1,4 @@ +package com.csse3200.game.components.minigames.maze; + +public class MazeGame { +} diff --git a/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/MazeCell.java b/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/MazeCell.java new file mode 100644 index 000000000..5a46b2969 --- /dev/null +++ b/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/MazeCell.java @@ -0,0 +1,26 @@ +package com.csse3200.game.components.minigames.maze.mazegrid; + +import com.badlogic.gdx.math.Rectangle; +import com.badlogic.gdx.math.Vector2; + +/** + * Class of maze cells for the maze game. + */ +public abstract class MazeCell { + protected Vector2 position; + protected Rectangle collisionBox; + + public MazeCell(int x, int y) { + this.position = new Vector2(x, y); + // Arbitrary height and width for now. will change + this.collisionBox = new Rectangle(x, y, 50, 50); + } + + public Vector2 getPosition() { + return this.position; + } + + public Rectangle getCollisionBox() { + return this.collisionBox; + } +} diff --git a/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/MazeGrid.java b/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/MazeGrid.java new file mode 100644 index 000000000..ebe085da2 --- /dev/null +++ b/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/MazeGrid.java @@ -0,0 +1,22 @@ +package com.csse3200.game.components.minigames.maze.mazegrid; + +import com.csse3200.game.components.minigames.Grid; + +public class MazeGrid{ + /** + * Creates a new Grid with the specified dimensions. + * Specialised Grid takes in a file path and converts it into a maze + * + * @param width The width of the grid (number of cells in the x-direction). + * @param height The height of the grid (number of cells in the y-direction). + */ + + private final String file; + private final int width; + private final int height; + public MazeGrid(int width, int height, String file) { + this.width = width; + this.height = height; + this.file = file; + } +} diff --git a/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/NotWall.java b/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/NotWall.java new file mode 100644 index 000000000..27831e1b7 --- /dev/null +++ b/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/NotWall.java @@ -0,0 +1,7 @@ +package com.csse3200.game.components.minigames.maze.mazegrid; + +public class NotWall extends MazeCell { + public NotWall(int x, int y) { + super(x, y); + } +} diff --git a/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/Wall.java b/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/Wall.java new file mode 100644 index 000000000..23b486739 --- /dev/null +++ b/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/Wall.java @@ -0,0 +1,7 @@ +package com.csse3200.game.components.minigames.maze.mazegrid; + +public class Wall extends MazeCell{ + public Wall(int x, int y) { + super(x, y); + } +} From 964dcd57ca2e941661668d2272775314caa7d976 Mon Sep 17 00:00:00 2001 From: 0NATE4 Date: Sat, 14 Sep 2024 11:18:42 +1000 Subject: [PATCH 02/19] Added functionality to create maze based off text file input --- .../minigames/maze/mazegrid/MazeGrid.java | 68 +++++++++++++++---- 1 file changed, 56 insertions(+), 12 deletions(-) diff --git a/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/MazeGrid.java b/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/MazeGrid.java index ebe085da2..eb6afba58 100644 --- a/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/MazeGrid.java +++ b/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/MazeGrid.java @@ -1,22 +1,66 @@ package com.csse3200.game.components.minigames.maze.mazegrid; -import com.csse3200.game.components.minigames.Grid; +import java.io.BufferedReader; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.IOException; +/** + * Represents a maze grid that is created from a file. + * The grid contains cells of type MazeCell, which can either be Wall or NotWall. + * The grid is built based on a text file where '1' represents a Wall and '0' represents a + * NotWall. + */ public class MazeGrid{ + + + private final String file; // File path to the maze + private final int size; // Size of the grid + private final MazeCell[][] cells; // 2D array representing the cells + + /** - * Creates a new Grid with the specified dimensions. - * Specialised Grid takes in a file path and converts it into a maze + * Creates a new MazeGrid with the specified dimensions. + * The maze is constructed by reading from the file, which contains '1's for walls and '0's + * for paths. * - * @param width The width of the grid (number of cells in the x-direction). - * @param height The height of the grid (number of cells in the y-direction). + * @param size The size of the maze grid. + * @param file The file path to the maze text file. */ - - private final String file; - private final int width; - private final int height; - public MazeGrid(int width, int height, String file) { - this.width = width; - this.height = height; + public MazeGrid(int size, String file) { + this.size = size; this.file = file; + this.cells = new MazeCell[size][size]; + createMaze(); + } + + /** + * Reads the file and constructs the maze by filling the cells array. + * Each character in the file is read, where '1' corresponds to a Wall and '0' to a NotWall. + */ + private void createMaze() { + try { + BufferedReader br = new BufferedReader(new FileReader(file)); + String line; + int row = 0; + // Read each line from the file + while ((line = br.readLine()) != null) { + for (int col = 0; col < line.length() && col < size; col++) { + char ch = line.charAt(col); + // Make a wall if it's a 1, otherwise normal path + if (ch == '1') { + cells[row][col] = new Wall(row, col); + } else { + cells[row][col] = new NotWall(row, col); + } + } + row++; + } + br.close(); + } catch (FileNotFoundException e) { + System.out.println("File path is wrong"); + } catch (IOException e) { + System.out.println("Can't read line"); + } } } From 86a30b6b6d64095b538b3c067f700a4d4ff5cc1c Mon Sep 17 00:00:00 2001 From: 0NATE4 Date: Sat, 14 Sep 2024 16:28:01 +1000 Subject: [PATCH 03/19] Added junit test to ensure maze gets created properly. Added a test maze file to ensure it works. --- source/core/assets/minigameMaze/TestMaze.txt | 10 ++++ .../maze/mazegrid/MazeFilePaths.java | 11 ++++ .../minigames/maze/mazegrid/MazeGrid.java | 10 ++++ .../minigames/maze/MazeGameTest.java | 4 ++ .../minigames/maze/mazegrid/MazeGridTest.java | 58 +++++++++++++++++++ 5 files changed, 93 insertions(+) create mode 100644 source/core/assets/minigameMaze/TestMaze.txt create mode 100644 source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/MazeFilePaths.java create mode 100644 source/core/src/test/com/csse3200/game/components/minigames/maze/MazeGameTest.java create mode 100644 source/core/src/test/com/csse3200/game/components/minigames/maze/mazegrid/MazeGridTest.java diff --git a/source/core/assets/minigameMaze/TestMaze.txt b/source/core/assets/minigameMaze/TestMaze.txt new file mode 100644 index 000000000..186aa25ba --- /dev/null +++ b/source/core/assets/minigameMaze/TestMaze.txt @@ -0,0 +1,10 @@ +1001010101 +1010101010 +0101010100 +1110000100 +1010101001 +1010101010 +1010101000 +0011101010 +0101010100 +0101010001 \ No newline at end of file diff --git a/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/MazeFilePaths.java b/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/MazeFilePaths.java new file mode 100644 index 000000000..3cd90c12e --- /dev/null +++ b/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/MazeFilePaths.java @@ -0,0 +1,11 @@ +package com.csse3200.game.components.minigames.maze.mazegrid; + +public class MazeFilePaths { + + static final String TEST_MAZE = "minigameMaze/TestMaze.txt"; + + + private MazeFilePaths() { + // Does not get initialised + } +} diff --git a/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/MazeGrid.java b/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/MazeGrid.java index eb6afba58..5e3fb65a7 100644 --- a/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/MazeGrid.java +++ b/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/MazeGrid.java @@ -34,6 +34,16 @@ public MazeGrid(int size, String file) { createMaze(); } + /*** + * Method to get the cell at a specific coordinate + * @param row the row + * @param col the column + * @return + */ + public MazeCell getCell(int row, int col) { + return cells[row][col]; + } + /** * Reads the file and constructs the maze by filling the cells array. * Each character in the file is read, where '1' corresponds to a Wall and '0' to a NotWall. diff --git a/source/core/src/test/com/csse3200/game/components/minigames/maze/MazeGameTest.java b/source/core/src/test/com/csse3200/game/components/minigames/maze/MazeGameTest.java new file mode 100644 index 000000000..34524f261 --- /dev/null +++ b/source/core/src/test/com/csse3200/game/components/minigames/maze/MazeGameTest.java @@ -0,0 +1,4 @@ +package com.csse3200.game.components.minigames.maze; + +public class MazeGameTest { +} diff --git a/source/core/src/test/com/csse3200/game/components/minigames/maze/mazegrid/MazeGridTest.java b/source/core/src/test/com/csse3200/game/components/minigames/maze/mazegrid/MazeGridTest.java new file mode 100644 index 000000000..d87eefbc8 --- /dev/null +++ b/source/core/src/test/com/csse3200/game/components/minigames/maze/mazegrid/MazeGridTest.java @@ -0,0 +1,58 @@ +package com.csse3200.game.components.minigames.maze.mazegrid; + +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.*; + +public class MazeGridTest { + + private MazeGrid mazeGrid; + + @Before + public void setup() { + this.mazeGrid = new MazeGrid(10, MazeFilePaths.TEST_MAZE); + } + + /** + * Tests if the first cell (0,0) in the grid is correctly parsed as a Wall. + */ + @Test + public void testFileParsing() { + assertTrue(mazeGrid.getCell(0,0) instanceof Wall); + } + + /** + * Tests the entire grid parsing logic by comparing the parsed maze grid + * to an expected grid layout. Verifies that each cell in the grid is + * correctly parsed as either a Wall or a NotWall. + */ + @Test + public void testFileParsingFullGrid() { + + int[][] expectedGrid = { + {1, 0, 0, 1, 0, 1, 0, 1, 0, 1}, + {1, 0, 1, 0, 1, 0, 1, 0, 1, 0}, + {0, 1, 0, 1, 0, 1, 0, 1, 0, 0}, + {1, 1, 1, 0, 0, 0, 0, 1, 0, 0}, + {1, 0, 1, 0, 1, 0, 1, 0, 0, 1}, + {1, 0, 1, 0, 1, 0, 1, 0, 1, 0}, + {1, 0, 1, 0, 1, 0, 1, 0, 0, 0}, + {0, 0, 1, 1, 1, 0, 1, 0, 1, 0}, + {0, 1, 0, 1, 0, 1, 0, 1, 0, 0}, + {0, 1, 0, 1, 0, 1, 0, 0, 0, 1} + }; + // Iterate over the grid and compare each cell to the expected values + for (int row = 0; row < expectedGrid.length; row++) { + for (int col = 0; col < expectedGrid[row].length; col++) { + if (expectedGrid[row][col] == 1) { + assertTrue("Expected Wall at (" + row + ", " + col + ") but found NotWall.", + mazeGrid.getCell(row, col) instanceof Wall); + } else { + assertTrue("Expected NotWall at (" + row + ", " + col + ") but found Wall.", + mazeGrid.getCell(row, col) instanceof NotWall); + } + } + } + } +} From 0c92d8bcfd003b498243ff40e9e044256933368f Mon Sep 17 00:00:00 2001 From: 0NATE4 Date: Sat, 14 Sep 2024 17:36:54 +1000 Subject: [PATCH 04/19] Added mazegame screen, added mazegame. Added rendering of grid onto screen --- source/core/assets/images/minigames/wall.png | Bin 0 -> 438 bytes source/core/assets/images/minigames/water.png | Bin 0 -> 436 bytes .../src/main/com/csse3200/game/GdxGame.java | 8 +- .../minigames/maze/MazeAssetPaths.java | 16 ++ .../components/minigames/maze/MazeGame.java | 25 +++ .../minigames/maze/mazegrid/MazeCell.java | 7 +- .../maze/mazegrid/MazeFilePaths.java | 11 - .../minigames/maze/mazegrid/MazeGrid.java | 50 ++++- .../mazegrid/{NotWall.java => Water.java} | 4 +- .../maze/rendering/MazeGridRenderer.java | 67 ++++++ .../minigames/snake/AssetPaths.java | 5 +- .../csse3200/game/screens/MazeGameScreen.java | 209 ++++++++++++++++++ .../game/screens/MiniGameMenuScreen.java | 2 + .../minigames/maze/mazegrid/MazeGridTest.java | 8 +- 14 files changed, 385 insertions(+), 27 deletions(-) create mode 100644 source/core/assets/images/minigames/wall.png create mode 100644 source/core/assets/images/minigames/water.png create mode 100644 source/core/src/main/com/csse3200/game/components/minigames/maze/MazeAssetPaths.java delete mode 100644 source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/MazeFilePaths.java rename source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/{NotWall.java => Water.java} (55%) create mode 100644 source/core/src/main/com/csse3200/game/components/minigames/maze/rendering/MazeGridRenderer.java create mode 100644 source/core/src/main/com/csse3200/game/screens/MazeGameScreen.java diff --git a/source/core/assets/images/minigames/wall.png b/source/core/assets/images/minigames/wall.png new file mode 100644 index 0000000000000000000000000000000000000000..0df626691278c4e2439af98e877b84e1c9dddd0d GIT binary patch literal 438 zcmeAS@N?(olHy`uVBq!ia0vp^DImu*Z1uJ9bG_#@z$ z#Fk_srsQ$Pf#Xazp00i_>zopr0G`>6Hvj+t literal 0 HcmV?d00001 diff --git a/source/core/src/main/com/csse3200/game/GdxGame.java b/source/core/src/main/com/csse3200/game/GdxGame.java index 9fd8959bd..74e9b0065 100644 --- a/source/core/src/main/com/csse3200/game/GdxGame.java +++ b/source/core/src/main/com/csse3200/game/GdxGame.java @@ -99,6 +99,10 @@ public void enterBirdieDashScreen() { addScreen(ScreenType.BIRD_MINI_GAME, getScreen(), null, null); } + public void enterMazeGameScreen() { + addScreen(ScreenType.MAZE_MINI_GAME, getScreen(), null, null); + } + /** * Overloaded to add new combat screen * Changes to a new screen, does NOT dispose of old screen @@ -153,6 +157,8 @@ private Screen newScreen(ScreenType screenType, Screen screen, ServiceContainer return new SnakeScreen(this, screen, container); case BIRD_MINI_GAME: return new BirdieDashScreen(this, screen, container); + case MAZE_MINI_GAME: + return new MazeGameScreen(this, screen, container); case LOADING_SCREEN: return new LoadingScreen(this); case ANIMAL_SELECTION: @@ -174,7 +180,7 @@ private Screen newScreen(ScreenType screenType, Screen screen, ServiceContainer public enum ScreenType { MAIN_MENU, MAIN_GAME, SETTINGS, MINI_GAME_MENU_SCREEN, LOADING_SCREEN, ANIMAL_SELECTION, ACHIEVEMENTS, COMBAT, BOSS_CUTSCENE, GAME_OVER_WIN, GAME_OVER_LOSE, SNAKE_MINI_GAME, - BIRD_MINI_GAME + BIRD_MINI_GAME, MAZE_MINI_GAME } /** diff --git a/source/core/src/main/com/csse3200/game/components/minigames/maze/MazeAssetPaths.java b/source/core/src/main/com/csse3200/game/components/minigames/maze/MazeAssetPaths.java new file mode 100644 index 000000000..aa27c1983 --- /dev/null +++ b/source/core/src/main/com/csse3200/game/components/minigames/maze/MazeAssetPaths.java @@ -0,0 +1,16 @@ +package com.csse3200.game.components.minigames.maze; + +public class MazeAssetPaths { + + // Mazes + public static final String TEST_MAZE = "minigameMaze/TestMaze.txt"; + + // Images + public static final String WATER = "images/minigames/water.png"; + public static final String WALL = "images/minigames/wall.png"; + + + private MazeAssetPaths() { + // Does not get initialised + } +} diff --git a/source/core/src/main/com/csse3200/game/components/minigames/maze/MazeGame.java b/source/core/src/main/com/csse3200/game/components/minigames/maze/MazeGame.java index 61b161110..a4b1d4fdd 100644 --- a/source/core/src/main/com/csse3200/game/components/minigames/maze/MazeGame.java +++ b/source/core/src/main/com/csse3200/game/components/minigames/maze/MazeGame.java @@ -1,4 +1,29 @@ package com.csse3200.game.components.minigames.maze; +import com.csse3200.game.components.minigames.MinigameRenderer; +import com.csse3200.game.components.minigames.maze.mazegrid.MazeGrid; +import com.csse3200.game.components.minigames.maze.rendering.MazeGridRenderer; +import com.csse3200.game.services.ResourceService; +import com.csse3200.game.services.ServiceLocator; + public class MazeGame { + + private final MazeGrid grid; + private final MinigameRenderer renderer; + + public MazeGame() { + this.grid = new MazeGrid(10, MazeAssetPaths.TEST_MAZE); + this.renderer = new MinigameRenderer(); + initRenderers(); + } + + private void initRenderers() { + ServiceLocator.registerResourceService(new ResourceService()); + renderer.addRenderable(new MazeGridRenderer(grid, renderer)); + } + + public void render() { + renderer.render(); + } } + diff --git a/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/MazeCell.java b/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/MazeCell.java index 5a46b2969..84eabf435 100644 --- a/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/MazeCell.java +++ b/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/MazeCell.java @@ -9,11 +9,16 @@ public abstract class MazeCell { protected Vector2 position; protected Rectangle collisionBox; + private final int TILE_SIZE = 50; public MazeCell(int x, int y) { this.position = new Vector2(x, y); // Arbitrary height and width for now. will change - this.collisionBox = new Rectangle(x, y, 50, 50); + this.collisionBox = new Rectangle(x, y, TILE_SIZE, TILE_SIZE); + } + + public int getSize() { + return TILE_SIZE; } public Vector2 getPosition() { diff --git a/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/MazeFilePaths.java b/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/MazeFilePaths.java deleted file mode 100644 index 3cd90c12e..000000000 --- a/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/MazeFilePaths.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.csse3200.game.components.minigames.maze.mazegrid; - -public class MazeFilePaths { - - static final String TEST_MAZE = "minigameMaze/TestMaze.txt"; - - - private MazeFilePaths() { - // Does not get initialised - } -} diff --git a/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/MazeGrid.java b/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/MazeGrid.java index 5e3fb65a7..f086a44e4 100644 --- a/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/MazeGrid.java +++ b/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/MazeGrid.java @@ -1,9 +1,9 @@ package com.csse3200.game.components.minigames.maze.mazegrid; -import java.io.BufferedReader; -import java.io.FileNotFoundException; -import java.io.FileReader; -import java.io.IOException; +import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.files.FileHandle; + +import java.io.*; /** * Represents a maze grid that is created from a file. @@ -44,11 +44,46 @@ public MazeCell getCell(int row, int col) { return cells[row][col]; } + public MazeCell[][] getMaze() { + return cells; + } + /** * Reads the file and constructs the maze by filling the cells array. * Each character in the file is read, where '1' corresponds to a Wall and '0' to a NotWall. */ private void createMaze() { + // For in game + if (isLibGDXEnvironemnt()) { + FileHandle fileHandle = Gdx.files.internal(file); // Use Gdx.files to load the file + String[] lines = fileHandle.readString().split("\n"); // Read the file content + + for (int row = 0; row < lines.length; row++) { + String line = lines[row]; + for (int col = 0; col < line.length() && col < size; col++) { + char ch = line.charAt(col); + if (ch == '1') { + cells[row][col] = new Wall(row, col); + } else { + cells[row][col] = new Water(row, col); + } + } + } + } + else { + setUpInTest(); + } + } + + /** + * Private method to check if in game or junit test + * @return whether it is game or junit environemnt + */ + private boolean isLibGDXEnvironemnt() { + return Gdx.files != null; + } + + private void setUpInTest() { try { BufferedReader br = new BufferedReader(new FileReader(file)); String line; @@ -57,20 +92,21 @@ private void createMaze() { while ((line = br.readLine()) != null) { for (int col = 0; col < line.length() && col < size; col++) { char ch = line.charAt(col); - // Make a wall if it's a 1, otherwise normal path + // Make a wall if it's a 1, otherwise water if (ch == '1') { cells[row][col] = new Wall(row, col); } else { - cells[row][col] = new NotWall(row, col); + cells[row][col] = new Water(row, col); } } row++; } br.close(); } catch (FileNotFoundException e) { - System.out.println("File path is wrong"); + System.out.println("Trying to read file from: " + new File(file).getAbsolutePath()); } catch (IOException e) { System.out.println("Can't read line"); } + } } diff --git a/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/NotWall.java b/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/Water.java similarity index 55% rename from source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/NotWall.java rename to source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/Water.java index 27831e1b7..85125db7c 100644 --- a/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/NotWall.java +++ b/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/Water.java @@ -1,7 +1,7 @@ package com.csse3200.game.components.minigames.maze.mazegrid; -public class NotWall extends MazeCell { - public NotWall(int x, int y) { +public class Water extends MazeCell { + public Water(int x, int y) { super(x, y); } } diff --git a/source/core/src/main/com/csse3200/game/components/minigames/maze/rendering/MazeGridRenderer.java b/source/core/src/main/com/csse3200/game/components/minigames/maze/rendering/MazeGridRenderer.java new file mode 100644 index 000000000..c77601d49 --- /dev/null +++ b/source/core/src/main/com/csse3200/game/components/minigames/maze/rendering/MazeGridRenderer.java @@ -0,0 +1,67 @@ +package com.csse3200.game.components.minigames.maze.rendering; + +import com.badlogic.gdx.graphics.Texture; +import com.csse3200.game.components.minigames.MinigameRenderable; +import com.csse3200.game.components.minigames.MinigameRenderer; +import com.csse3200.game.components.minigames.maze.MazeAssetPaths; +import com.csse3200.game.components.minigames.maze.mazegrid.MazeCell; +import com.csse3200.game.components.minigames.maze.mazegrid.MazeGrid; +import com.csse3200.game.components.minigames.maze.mazegrid.Wall; +import com.csse3200.game.services.ResourceService; +import com.csse3200.game.services.ServiceLocator; + +public class MazeGridRenderer implements MinigameRenderable { + + private final MazeCell[][] maze; + private final MinigameRenderer renderer; + private Texture waterTexture; + private Texture wallTexture; + + public MazeGridRenderer(MazeGrid grid, MinigameRenderer renderer) { + this.maze = grid.getMaze(); + this.renderer = renderer; + loadAssets(); + } + + public void render() { + for (int row = 0; row < maze.length; row++) { + for (int col = 0; col < maze[row].length; col++) { + MazeCell cell = maze[row][col]; + // Use renderer to draw the corresponding texture + if (cell instanceof Wall) { + renderer.getSb().draw(wallTexture, col * cell.getSize(), row * cell.getSize()); + } else { + renderer.getSb().draw(waterTexture, col * cell.getSize(), row * cell.getSize()); + } + } + } + } + + /** + * load assets + */ + private void loadAssets() { + ResourceService rs = ServiceLocator.getResourceService(); + rs.loadTextures(new String[]{MazeAssetPaths.WATER, MazeAssetPaths.WALL}); + ServiceLocator.getResourceService().loadAll(); + waterTexture = rs.getAsset(MazeAssetPaths.WATER, Texture.class); + wallTexture = rs.getAsset(MazeAssetPaths.WALL, Texture.class); + } + + /** + * unload assets + */ + private void unloadAssets() { + ResourceService rs = ServiceLocator.getResourceService(); + rs.unloadAssets(new String[]{MazeAssetPaths.WATER, MazeAssetPaths.WALL}); + } + + /** + * dispose + */ + public void dispose() { + unloadAssets(); + waterTexture.dispose(); + wallTexture.dispose(); + } +} diff --git a/source/core/src/main/com/csse3200/game/components/minigames/snake/AssetPaths.java b/source/core/src/main/com/csse3200/game/components/minigames/snake/AssetPaths.java index 6b35537db..4f75afd53 100644 --- a/source/core/src/main/com/csse3200/game/components/minigames/snake/AssetPaths.java +++ b/source/core/src/main/com/csse3200/game/components/minigames/snake/AssetPaths.java @@ -10,8 +10,6 @@ public class AssetPaths { public static final String GRASS_IMAGE = "images/minigames/grass.jpg"; public static final String SNAKE_BODY_HORIZONTAL_IMAGE = "images/minigames/snakebodyhorizontal.png"; public static final String SNAKE_BODY_VERTICAL_IMAGE = "images/minigames/snakebodyvertical.png"; - - public static final String SNAKE_BODY_BENT_IMAGE = "images/minigames/snakebodybent.png"; // Bird @@ -21,6 +19,9 @@ public class AssetPaths { public static final String BACKGROUND = "images/BackgroundSplashBasic.png"; public static final String COIN = "images/minigames/coin.png"; + // Maze + + public static final String[] IMAGES = { APPLE_IMAGE, SNAKE_HEAD_IMAGE, diff --git a/source/core/src/main/com/csse3200/game/screens/MazeGameScreen.java b/source/core/src/main/com/csse3200/game/screens/MazeGameScreen.java new file mode 100644 index 000000000..edc9ded65 --- /dev/null +++ b/source/core/src/main/com/csse3200/game/screens/MazeGameScreen.java @@ -0,0 +1,209 @@ +package com.csse3200.game.screens; + +import com.badlogic.gdx.graphics.g2d.BitmapFont; +import com.badlogic.gdx.scenes.scene2d.InputEvent; +import com.badlogic.gdx.scenes.scene2d.Stage; +import com.badlogic.gdx.scenes.scene2d.ui.Skin; +import com.badlogic.gdx.scenes.scene2d.ui.Table; +import com.badlogic.gdx.scenes.scene2d.ui.TextButton; +import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; +import com.badlogic.gdx.Screen; +import com.csse3200.game.components.minigames.KeyboardMiniGameInputComponent; +import com.csse3200.game.components.minigames.birdieDash.BirdieDashGame; +import com.csse3200.game.components.minigames.birdieDash.controller.KeyboardBirdInputComponent; +import com.csse3200.game.components.minigames.maze.MazeGame; +import com.csse3200.game.input.InputComponent; +import com.csse3200.game.input.InputDecorator; +import com.csse3200.game.rendering.Renderer; +import com.csse3200.game.services.ServiceContainer; +import com.csse3200.game.ui.minigames.ScoreBoard; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.graphics.Color; +import com.badlogic.gdx.graphics.GL20; +import com.csse3200.game.GdxGame; +import com.csse3200.game.entities.Entity; +import com.csse3200.game.entities.EntityService; +import com.csse3200.game.entities.factories.RenderFactory; +import com.csse3200.game.input.InputService; +import com.csse3200.game.rendering.RenderService; +import com.csse3200.game.services.GameTime; +import com.csse3200.game.services.ServiceLocator; +import com.csse3200.game.components.gamearea.PerformanceDisplay; + +import static com.csse3200.game.components.minigames.MiniGameNames.BIRD; + +/** + * Class for Birdie Dash Game Screen + */ +public class MazeGameScreen extends PausableScreen { + + private static final Logger logger = LoggerFactory.getLogger(BirdieDashScreen.class); + private final Renderer renderer; + private final BitmapFont font; + private final Skin skin; + private final Stage stage; + private float scale; + private final Table exitButtonTable; + private final ScoreBoard scoreBoard; + private final Screen oldScreen; + private final ServiceContainer oldScreenServices; + private final MazeGame mazeGame; + + public MazeGameScreen(GdxGame game, Screen screen, ServiceContainer container) { + super(game); + this.scale = 1; + this.exitButtonTable = new Table(); + this.oldScreen = screen; + this.oldScreenServices = container; + this.skin = new Skin(Gdx.files.internal("flat-earth/skin/flat-earth-ui.json")); + logger.debug("Initialising birdie dash screen services"); + ServiceLocator.registerInputService(new InputService()); + ServiceLocator.registerEntityService(new EntityService()); + ServiceLocator.registerRenderService(new RenderService()); + ServiceLocator.registerTimeSource(new GameTime()); + + renderer = RenderFactory.createRenderer(); + + font = new BitmapFont(); + font.setColor(Color.WHITE); + font.getData().setScale(5.0f); + + this.stage = ServiceLocator.getRenderService().getStage(); + this.mazeGame = new MazeGame(); + + this.scoreBoard = new ScoreBoard(0, BIRD); + +// logger.debug("Initialising birdie dash entities"); + + setupExitButton(); + createUI(); + } + + /** + * Renders the game + * @param delta The time in seconds since the last render. + */ + @Override + public void render(float delta) { + if (!resting) { + for (int i = 0; i < 20; i++) { +// birdGame.update(delta / 20); + } + } + + clearBackground(); + mazeGame.render(); + +// scoreBoard.updateScore(birdGame.getScore()); + + stage.act(delta); // Update the stage + stage.draw(); // Draw the UI (pause overlay) + } + + + + /** + * Clears the screen background + */ + public void clearBackground() { + Gdx.gl.glClearColor(50f / 255f, 82f / 255f, 29f / 255f, 1f); + Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); + } + + /** + * Resizes the game based on screen size. + * @param width new screen width + * @param height new screen height + */ + @Override + public void resize(int width, int height) { + stage.getViewport().update(width, height, true); + float baseWidth = 1920; + float baseHeight = 1200; + float scaleWidth = width / baseWidth; + float scaleHeight = height / baseHeight; + scale = Math.min(scaleWidth, scaleHeight); + setupExitButton(); + scoreBoard.resize(); + } + + /** + * Dispose of assets + */ + @Override + public void dispose() { + Gdx.gl.glClearColor(248f / 255f, 249f / 255f, 178f / 255f, 1f); + + logger.debug("Disposing birdie dash screen"); + + renderer.dispose(); + ServiceLocator.getEntityService().dispose(); + ServiceLocator.getRenderService().dispose(); + ServiceLocator.clear(); + font.dispose(); + skin.dispose(); + stage.dispose(); + } + + /** + * Set up the exit button in the top right + */ + private void setupExitButton() { + exitButtonTable.clear(); + TextButton exitButton = new TextButton("Exit", skin); + exitButton.getLabel().setFontScale(scale); + + exitButton.addListener(new ClickListener() { + @Override + public void clicked(InputEvent event, float x, float y) { + Gdx.gl.glClearColor(248f / 255f, 249f / 255f, 178f / 255f, 1f); + exitGame(); + } + }); + + exitButtonTable.setFillParent(true); + exitButtonTable.top().right(); + exitButtonTable.add(exitButton).width(exitButton.getWidth() * scale).height(exitButton.getHeight() * scale).center().pad(10 * scale).row(); + stage.addActor(exitButtonTable); + } + + /** + * set up ui for key inputs + */ + private void createUI() { + logger.debug("Creating birdie dash ui"); + Stage stage = ServiceLocator.getRenderService().getStage(); + InputComponent inputComponent = new KeyboardBirdInputComponent(); + + Entity ui = new Entity(); + ui + .addComponent(new InputDecorator(stage, 10)) + .addComponent(new PerformanceDisplay()) + .addComponent(inputComponent) + .addComponent(new KeyboardMiniGameInputComponent()); + + ui.getEvents().addListener("addOverlay", this::addOverlay); + ui.getEvents().addListener("removeOverlay", this::removeOverlay); + ui.getEvents().addListener("restart", this::restartGame); + ui.getEvents().addListener("exit", this::exitGame); + + ServiceLocator.getEntityService().register(ui); + } + + /** + * Called from event to restart the game + */ + void restartGame() { + dispose(); + game.setScreen(new MazeGameScreen(game, oldScreen, oldScreenServices)); + } + + /** + * Called from event to exit the game back to the previous screen + */ + void exitGame() { + game.setOldScreen(oldScreen, oldScreenServices); + } +} diff --git a/source/core/src/main/com/csse3200/game/screens/MiniGameMenuScreen.java b/source/core/src/main/com/csse3200/game/screens/MiniGameMenuScreen.java index 51b51f9ba..80d7d078d 100644 --- a/source/core/src/main/com/csse3200/game/screens/MiniGameMenuScreen.java +++ b/source/core/src/main/com/csse3200/game/screens/MiniGameMenuScreen.java @@ -145,6 +145,7 @@ public void clicked(InputEvent event, float x, float y) { @Override public void clicked(InputEvent event, float x, float y) { waterImage.setColor(Color.GREEN); + game.enterMazeGameScreen(); } }); @@ -168,6 +169,7 @@ public void clicked(InputEvent event, float x, float y) { @Override public void clicked(InputEvent event, float x, float y) { waterButton.setColor(Color.GREEN); + game.enterMazeGameScreen(); } }); } diff --git a/source/core/src/test/com/csse3200/game/components/minigames/maze/mazegrid/MazeGridTest.java b/source/core/src/test/com/csse3200/game/components/minigames/maze/mazegrid/MazeGridTest.java index d87eefbc8..6073f024f 100644 --- a/source/core/src/test/com/csse3200/game/components/minigames/maze/mazegrid/MazeGridTest.java +++ b/source/core/src/test/com/csse3200/game/components/minigames/maze/mazegrid/MazeGridTest.java @@ -1,5 +1,6 @@ package com.csse3200.game.components.minigames.maze.mazegrid; +import com.csse3200.game.components.minigames.maze.MazeAssetPaths; import org.junit.Before; import org.junit.Test; @@ -11,7 +12,8 @@ public class MazeGridTest { @Before public void setup() { - this.mazeGrid = new MazeGrid(10, MazeFilePaths.TEST_MAZE); + + this.mazeGrid = new MazeGrid(10, MazeAssetPaths.TEST_MAZE); } /** @@ -49,8 +51,8 @@ public void testFileParsingFullGrid() { assertTrue("Expected Wall at (" + row + ", " + col + ") but found NotWall.", mazeGrid.getCell(row, col) instanceof Wall); } else { - assertTrue("Expected NotWall at (" + row + ", " + col + ") but found Wall.", - mazeGrid.getCell(row, col) instanceof NotWall); + assertTrue("Expected Water at (" + row + ", " + col + ") but found Wall.", + mazeGrid.getCell(row, col) instanceof Water); } } } From 3c1ac00b0397993b697a1e61f30df4064e791eb5 Mon Sep 17 00:00:00 2001 From: 0NATE4 Date: Sat, 14 Sep 2024 18:15:19 +1000 Subject: [PATCH 05/19] Fixed rendering position --- source/core/assets/minigameMaze/MazeOne.txt | 10 ++++++++ .../minigames/maze/MazeAssetPaths.java | 1 + .../components/minigames/maze/MazeGame.java | 2 +- .../minigames/maze/mazegrid/MazeCell.java | 2 +- .../minigames/maze/mazegrid/MazeGrid.java | 15 ++++++++++++ .../maze/rendering/MazeGridRenderer.java | 23 +++++++++++++++++-- 6 files changed, 49 insertions(+), 4 deletions(-) create mode 100644 source/core/assets/minigameMaze/MazeOne.txt diff --git a/source/core/assets/minigameMaze/MazeOne.txt b/source/core/assets/minigameMaze/MazeOne.txt new file mode 100644 index 000000000..da87d32dd --- /dev/null +++ b/source/core/assets/minigameMaze/MazeOne.txt @@ -0,0 +1,10 @@ +1000100001 +1000100001 +1000100001 +1000100001 +1000100001 +1000100001 +1000100001 +1000100001 +1000100001 +1111111111 \ No newline at end of file diff --git a/source/core/src/main/com/csse3200/game/components/minigames/maze/MazeAssetPaths.java b/source/core/src/main/com/csse3200/game/components/minigames/maze/MazeAssetPaths.java index aa27c1983..20299a624 100644 --- a/source/core/src/main/com/csse3200/game/components/minigames/maze/MazeAssetPaths.java +++ b/source/core/src/main/com/csse3200/game/components/minigames/maze/MazeAssetPaths.java @@ -4,6 +4,7 @@ public class MazeAssetPaths { // Mazes public static final String TEST_MAZE = "minigameMaze/TestMaze.txt"; + public static final String MAZE_ONE = "minigameMaze/MazeOne.txt"; // Images public static final String WATER = "images/minigames/water.png"; diff --git a/source/core/src/main/com/csse3200/game/components/minigames/maze/MazeGame.java b/source/core/src/main/com/csse3200/game/components/minigames/maze/MazeGame.java index a4b1d4fdd..bd14ede0e 100644 --- a/source/core/src/main/com/csse3200/game/components/minigames/maze/MazeGame.java +++ b/source/core/src/main/com/csse3200/game/components/minigames/maze/MazeGame.java @@ -12,7 +12,7 @@ public class MazeGame { private final MinigameRenderer renderer; public MazeGame() { - this.grid = new MazeGrid(10, MazeAssetPaths.TEST_MAZE); + this.grid = new MazeGrid(10, MazeAssetPaths.MAZE_ONE); this.renderer = new MinigameRenderer(); initRenderers(); } diff --git a/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/MazeCell.java b/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/MazeCell.java index 84eabf435..5c7400683 100644 --- a/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/MazeCell.java +++ b/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/MazeCell.java @@ -9,7 +9,7 @@ public abstract class MazeCell { protected Vector2 position; protected Rectangle collisionBox; - private final int TILE_SIZE = 50; + private final int TILE_SIZE = 100; public MazeCell(int x, int y) { this.position = new Vector2(x, y); diff --git a/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/MazeGrid.java b/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/MazeGrid.java index f086a44e4..5b0c2ba74 100644 --- a/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/MazeGrid.java +++ b/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/MazeGrid.java @@ -18,6 +18,13 @@ public class MazeGrid{ private final int size; // Size of the grid private final MazeCell[][] cells; // 2D array representing the cells + // Screen size + private final float screenWidth = 1920f; + private final float screenHeight = 1200f; + private final float gridWidth = 1000; + private final float gridHeight = 1000; + private float gridX; + private float gridY; /** * Creates a new MazeGrid with the specified dimensions. @@ -32,6 +39,12 @@ public MazeGrid(int size, String file) { this.file = file; this.cells = new MazeCell[size][size]; createMaze(); + calculateCellDimensions(); + } + + private void calculateCellDimensions() { + this.gridX = (screenWidth - gridWidth) / 2; // Center the grid horizontally + this.gridY = (screenHeight - gridHeight) / 2; // Center the grid vertically } /*** @@ -75,6 +88,8 @@ private void createMaze() { } } + + /** * Private method to check if in game or junit test * @return whether it is game or junit environemnt diff --git a/source/core/src/main/com/csse3200/game/components/minigames/maze/rendering/MazeGridRenderer.java b/source/core/src/main/com/csse3200/game/components/minigames/maze/rendering/MazeGridRenderer.java index c77601d49..1942e8460 100644 --- a/source/core/src/main/com/csse3200/game/components/minigames/maze/rendering/MazeGridRenderer.java +++ b/source/core/src/main/com/csse3200/game/components/minigames/maze/rendering/MazeGridRenderer.java @@ -17,9 +17,24 @@ public class MazeGridRenderer implements MinigameRenderable { private Texture waterTexture; private Texture wallTexture; + // Screen dimensions + private final float screenWidth = 1920f; + private final float screenHeight = 1200f; + + // Desired grid area size + private final float gridSize = 1000f; + + // Calculated starting positions for centering the grid + private final float gridX = (screenWidth - gridSize) / 2; // Horizontal center + private final float gridY = (screenHeight - gridSize) / 2; // Vertical center + + // The size of each cell + private final float cellSize; + public MazeGridRenderer(MazeGrid grid, MinigameRenderer renderer) { this.maze = grid.getMaze(); this.renderer = renderer; + this.cellSize = gridSize / grid.getMaze().length; // Divide the grid size by the number of rows/columns loadAssets(); } @@ -27,11 +42,15 @@ public void render() { for (int row = 0; row < maze.length; row++) { for (int col = 0; col < maze[row].length; col++) { MazeCell cell = maze[row][col]; + // Calculate position of each cell based on grid position and cell size + float x = gridX + col * cellSize; + float y = gridY + (maze.length - row - 1) * cellSize; // Inverted Y-axis for LibGDX + // Use renderer to draw the corresponding texture if (cell instanceof Wall) { - renderer.getSb().draw(wallTexture, col * cell.getSize(), row * cell.getSize()); + renderer.getSb().draw(wallTexture, x, y, cellSize, cellSize); } else { - renderer.getSb().draw(waterTexture, col * cell.getSize(), row * cell.getSize()); + renderer.getSb().draw(waterTexture, x, y, cellSize, cellSize); } } } From cbfe338dd9dd126d51643754b65b102f262ae98d Mon Sep 17 00:00:00 2001 From: 0NATE4 Date: Sat, 14 Sep 2024 20:07:56 +1000 Subject: [PATCH 06/19] Maze now renders properly. Can now also handle any grid dimension given via text file --- source/core/assets/minigameMaze/maze2.txt | 31 ++++++++++++++++ .../minigames/maze/MazeAssetPaths.java | 1 + .../components/minigames/maze/MazeGame.java | 2 +- .../minigames/maze/mazegrid/MazeCell.java | 16 ++++++--- .../minigames/maze/mazegrid/MazeGrid.java | 36 +++++++++++-------- .../minigames/maze/mazegrid/Wall.java | 4 +-- .../minigames/maze/mazegrid/Water.java | 4 +-- .../maze/rendering/MazeGridRenderer.java | 27 +++++--------- 8 files changed, 79 insertions(+), 42 deletions(-) create mode 100644 source/core/assets/minigameMaze/maze2.txt diff --git a/source/core/assets/minigameMaze/maze2.txt b/source/core/assets/minigameMaze/maze2.txt new file mode 100644 index 000000000..acea2b8bf --- /dev/null +++ b/source/core/assets/minigameMaze/maze2.txt @@ -0,0 +1,31 @@ +1111111111111111111111111111111 +1000000010000010000010000000001 +1011101010111010101110111011101 +1X10001010101010100000100010101 +1110111010101010111111101110101 +10001X1010001000100000001010001 +1011101011101111101111111010111 +101000101X001000001X001000001X1 +1010111011111011111110101111101 +1010000010000010000010101000001 +1011101110111110111010101110101 +1000100000100000100010000010101 +1010111011101111101111111010111 +1010001010001010001000001010001 +1011101010111010101011101011101 +1010001010100010101010101010001 +1010111110101010111010101010111 +1010000000101010001000101010001 +1011111111101011101110101011101 +1000001000001010000010101000101 +1111101010111010111110101110101 +1X10001010100010000000101010001 +1010111110101111111111101011101 +1010100010101000100000101010001 +1010101010101010101110101010111 +101000101010001X100010001000101 +1011111010111111101011111011101 +10000010001000001010100X1000101 +1011111110111110111010111110101 +1000000000000010000010000000001 +1111111111111111111111111111111 \ No newline at end of file diff --git a/source/core/src/main/com/csse3200/game/components/minigames/maze/MazeAssetPaths.java b/source/core/src/main/com/csse3200/game/components/minigames/maze/MazeAssetPaths.java index 20299a624..0e4663d9c 100644 --- a/source/core/src/main/com/csse3200/game/components/minigames/maze/MazeAssetPaths.java +++ b/source/core/src/main/com/csse3200/game/components/minigames/maze/MazeAssetPaths.java @@ -5,6 +5,7 @@ public class MazeAssetPaths { // Mazes public static final String TEST_MAZE = "minigameMaze/TestMaze.txt"; public static final String MAZE_ONE = "minigameMaze/MazeOne.txt"; + public static final String MAZE_TWO = "minigameMaze/maze2.txt"; // Images public static final String WATER = "images/minigames/water.png"; diff --git a/source/core/src/main/com/csse3200/game/components/minigames/maze/MazeGame.java b/source/core/src/main/com/csse3200/game/components/minigames/maze/MazeGame.java index bd14ede0e..d987d486b 100644 --- a/source/core/src/main/com/csse3200/game/components/minigames/maze/MazeGame.java +++ b/source/core/src/main/com/csse3200/game/components/minigames/maze/MazeGame.java @@ -12,7 +12,7 @@ public class MazeGame { private final MinigameRenderer renderer; public MazeGame() { - this.grid = new MazeGrid(10, MazeAssetPaths.MAZE_ONE); + this.grid = new MazeGrid(31, MazeAssetPaths.MAZE_TWO); this.renderer = new MinigameRenderer(); initRenderers(); } diff --git a/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/MazeCell.java b/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/MazeCell.java index 5c7400683..671982027 100644 --- a/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/MazeCell.java +++ b/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/MazeCell.java @@ -9,22 +9,28 @@ public abstract class MazeCell { protected Vector2 position; protected Rectangle collisionBox; - private final int TILE_SIZE = 100; + private float tileSize; - public MazeCell(int x, int y) { + public MazeCell(float x, float y, float size) { this.position = new Vector2(x, y); + this.tileSize = size; // Arbitrary height and width for now. will change - this.collisionBox = new Rectangle(x, y, TILE_SIZE, TILE_SIZE); + this.collisionBox = new Rectangle(x, y, tileSize, tileSize); } - public int getSize() { - return TILE_SIZE; + public float getSize() { + return tileSize; + } + + public void setPosition(float x, float y) { + position.set(x, y); } public Vector2 getPosition() { return this.position; } + public Rectangle getCollisionBox() { return this.collisionBox; } diff --git a/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/MazeGrid.java b/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/MazeGrid.java index 5b0c2ba74..3fbfda743 100644 --- a/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/MazeGrid.java +++ b/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/MazeGrid.java @@ -2,6 +2,7 @@ import com.badlogic.gdx.Gdx; import com.badlogic.gdx.files.FileHandle; +import com.badlogic.gdx.math.Vector2; import java.io.*; @@ -25,6 +26,7 @@ public class MazeGrid{ private final float gridHeight = 1000; private float gridX; private float gridY; + private float cellSize; /** * Creates a new MazeGrid with the specified dimensions. @@ -38,13 +40,15 @@ public MazeGrid(int size, String file) { this.size = size; this.file = file; this.cells = new MazeCell[size][size]; - createMaze(); calculateCellDimensions(); + createMaze(); + } private void calculateCellDimensions() { this.gridX = (screenWidth - gridWidth) / 2; // Center the grid horizontally this.gridY = (screenHeight - gridHeight) / 2; // Center the grid vertically + this.cellSize = gridWidth / size; } /*** @@ -66,7 +70,6 @@ public MazeCell[][] getMaze() { * Each character in the file is read, where '1' corresponds to a Wall and '0' to a NotWall. */ private void createMaze() { - // For in game if (isLibGDXEnvironemnt()) { FileHandle fileHandle = Gdx.files.internal(file); // Use Gdx.files to load the file String[] lines = fileHandle.readString().split("\n"); // Read the file content @@ -75,24 +78,26 @@ private void createMaze() { String line = lines[row]; for (int col = 0; col < line.length() && col < size; col++) { char ch = line.charAt(col); + // Calculate the position for this cell + float x = gridX + col * cellSize; + float y = gridY + (size - row - 1) * cellSize; // Correctly calculate the Y position + System.out.println(new Vector2(x,y)); + if (ch == '1') { - cells[row][col] = new Wall(row, col); + cells[row][col] = new Wall(x, y, cellSize); } else { - cells[row][col] = new Water(row, col); + cells[row][col] = new Water(x, y, cellSize); } } } - } - else { + } else { setUpInTest(); } } - - /** - * Private method to check if in game or junit test - * @return whether it is game or junit environemnt + * Private method to check if in-game or JUnit test + * @return whether it is game or test environment */ private boolean isLibGDXEnvironemnt() { return Gdx.files != null; @@ -107,11 +112,15 @@ private void setUpInTest() { while ((line = br.readLine()) != null) { for (int col = 0; col < line.length() && col < size; col++) { char ch = line.charAt(col); - // Make a wall if it's a 1, otherwise water + // Calculate the position for this cell + float x = gridX + col * cellSize; + float y = gridY + (size - row - 1) * cellSize; + + // Make a wall if it's a '1', otherwise Water cell if (ch == '1') { - cells[row][col] = new Wall(row, col); + cells[row][col] = new Wall(x, y, cellSize); } else { - cells[row][col] = new Water(row, col); + cells[row][col] = new Water(x, y, cellSize); } } row++; @@ -122,6 +131,5 @@ private void setUpInTest() { } catch (IOException e) { System.out.println("Can't read line"); } - } } diff --git a/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/Wall.java b/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/Wall.java index 23b486739..e73dcee4d 100644 --- a/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/Wall.java +++ b/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/Wall.java @@ -1,7 +1,7 @@ package com.csse3200.game.components.minigames.maze.mazegrid; public class Wall extends MazeCell{ - public Wall(int x, int y) { - super(x, y); + public Wall(float x, float y, float size) { + super(x, y, size); } } diff --git a/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/Water.java b/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/Water.java index 85125db7c..d7b93700e 100644 --- a/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/Water.java +++ b/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/Water.java @@ -1,7 +1,7 @@ package com.csse3200.game.components.minigames.maze.mazegrid; public class Water extends MazeCell { - public Water(int x, int y) { - super(x, y); + public Water(float x, float y, float size) { + super(x, y, size); } } diff --git a/source/core/src/main/com/csse3200/game/components/minigames/maze/rendering/MazeGridRenderer.java b/source/core/src/main/com/csse3200/game/components/minigames/maze/rendering/MazeGridRenderer.java index 1942e8460..6ee1b8548 100644 --- a/source/core/src/main/com/csse3200/game/components/minigames/maze/rendering/MazeGridRenderer.java +++ b/source/core/src/main/com/csse3200/game/components/minigames/maze/rendering/MazeGridRenderer.java @@ -17,24 +17,11 @@ public class MazeGridRenderer implements MinigameRenderable { private Texture waterTexture; private Texture wallTexture; - // Screen dimensions - private final float screenWidth = 1920f; - private final float screenHeight = 1200f; - // Desired grid area size - private final float gridSize = 1000f; - - // Calculated starting positions for centering the grid - private final float gridX = (screenWidth - gridSize) / 2; // Horizontal center - private final float gridY = (screenHeight - gridSize) / 2; // Vertical center - - // The size of each cell - private final float cellSize; public MazeGridRenderer(MazeGrid grid, MinigameRenderer renderer) { this.maze = grid.getMaze(); this.renderer = renderer; - this.cellSize = gridSize / grid.getMaze().length; // Divide the grid size by the number of rows/columns loadAssets(); } @@ -42,18 +29,22 @@ public void render() { for (int row = 0; row < maze.length; row++) { for (int col = 0; col < maze[row].length; col++) { MazeCell cell = maze[row][col]; - // Calculate position of each cell based on grid position and cell size - float x = gridX + col * cellSize; - float y = gridY + (maze.length - row - 1) * cellSize; // Inverted Y-axis for LibGDX // Use renderer to draw the corresponding texture if (cell instanceof Wall) { - renderer.getSb().draw(wallTexture, x, y, cellSize, cellSize); + renderer.getSb().draw(wallTexture, cell.getPosition().x, + cell.getPosition().y, + cell.getSize(), + cell.getSize()); } else { - renderer.getSb().draw(waterTexture, x, y, cellSize, cellSize); + renderer.getSb().draw(waterTexture,cell.getPosition().x, + cell.getPosition().y, + cell.getSize(), + cell.getSize()); } } } + } /** From b013adb23fda0d08ee65d219c8c24f7763c8509d Mon Sep 17 00:00:00 2001 From: 0NATE4 Date: Sat, 14 Sep 2024 23:16:29 +1000 Subject: [PATCH 07/19] Added more mazes --- saves/quests.json | 8 +- .../assets/minigameMaze/expanded_maze.txt | 41 ++++ source/core/assets/minigameMaze/maze5.txt | 37 ++++ source/core/assets/minigameMaze/maze6.txt | 201 ++++++++++++++++++ .../minigames/maze/MazeAssetPaths.java | 3 + .../components/minigames/maze/MazeGame.java | 2 +- .../minigames/maze/mazegrid/MazeGrid.java | 2 +- 7 files changed, 288 insertions(+), 6 deletions(-) create mode 100644 source/core/assets/minigameMaze/expanded_maze.txt create mode 100644 source/core/assets/minigameMaze/maze5.txt create mode 100644 source/core/assets/minigameMaze/maze6.txt diff --git a/saves/quests.json b/saves/quests.json index c700c9e3c..fd41f4448 100644 --- a/saves/quests.json +++ b/saves/quests.json @@ -53,15 +53,15 @@ quests: [ isSecretQuest: false questDialogue: { class: java.util.ImmutableCollections$MapN + TupleKey{str='Cow', num=2}: [ + Yippeee! + You completed your Quest! + ] TupleKey{str='Cow', num=1}: [ Welcome to Animal Kingdom! Here let me help with your quest... Press Spacebar! ] - TupleKey{str='Cow', num=2}: [ - Yippeee! - You completed your Quest! - ] } currentTaskIndex: 0 isFailed: false diff --git a/source/core/assets/minigameMaze/expanded_maze.txt b/source/core/assets/minigameMaze/expanded_maze.txt new file mode 100644 index 000000000..3ee350114 --- /dev/null +++ b/source/core/assets/minigameMaze/expanded_maze.txt @@ -0,0 +1,41 @@ +0001111111111111111111111111111111111111111111111111111111111 +0000000000001000000000000001000000000001000000001000000000001 +1001001001111001111001111001001001111111001111001111001111001 +1001001000000000001000001001001000001000001000000000001000001 +1001111001111111001111111111001111111111001001111001111001111 +1000001001001000001001000000000001001000001001001000001000001 +1111111001001111001001001111111001001111111001001111001111001 +1000000001000000001001001001000001001000001000001001001000001 +1001111001001001111001111001001111001001111111111001111111001 +1001000001001000001000001001000001001001000000001000001000001 +1001111111001001111111001001001001001001001001111111001111001 +1000000001001000001001001000001000000000001000000001000001001 +1111001111111111001001001001111001001111111111111001111001001 +1000001000001001000001000001000001001001000000000000000001001 +1001111001111001111111001111001111111001111111111001111111001 +1001000000000001000000001000000000000000000001000000000000001 +1001001111111111111001001001111111111111111111111001001111111 +1000001000001000000001001000001001001001001001001001001001001 +1001111001001111001111111111111001001001001001001111001001001 +1001000001001000000001000000000001001000001000000001001000001 +1001111111001001001111001111001111001111001111111001001001111 +1000000000000001000000001001000001001000000001001000000001001 +1111111111001111111111001001001111001111001111001001111111001 +1000000000000000001000000001000001000000001000000001000000001 +1001111001001111001001111001111111111001111111111001001111111 +1001000001001000001000001000000001000001000001001001001001001 +1001111001001111111111111111111111001001001001001001001001001 +1001001001000000000000001000001000001001001000000001000000001 +1001001111111111001111111111001001111111111001111001111001111 +1001000001000001000000001000001001000001000000001000000000001 +1001001001111001001111001001001001111001001111001111001111001 +1000001000001000000001001001000000000001001001001001001001001 +1001111001001111111111001001001111111111111001001001001001001 +1001000001000000001000000001000000000000001000000001000001001 +1001111111001111111111001111111111111001111001111111001111001 +1000001001001000001001000000000001001001000001001000000001001 +1001111001001001111001001111111001001001111001001111001111111 +1001001001000000001000000000001001001000001001000001000000001 +1001001001001001111111111111001111001001001001001111111001111 +1000001000001001000000000000001000000001001000000001000000000 +1111111111111111111111111111111111111111111111111111111111000 \ No newline at end of file diff --git a/source/core/assets/minigameMaze/maze5.txt b/source/core/assets/minigameMaze/maze5.txt new file mode 100644 index 000000000..0a3d45401 --- /dev/null +++ b/source/core/assets/minigameMaze/maze5.txt @@ -0,0 +1,37 @@ +1111111111111111111111111111111111111 +1X0010000000000000000000000X100000001 +1000100000000000000000000000100000001 +1000100000000000000000000000100000001 +1000100011111111100011111111100010001 +100000001000000X100000000000000010001 +1000000010000000100000000000000010001 +1000000010000000100000000000000010001 +1000111110001111111110001111111110001 +1000000000001000000010000000100000001 +1000000000001000000010000000100000001 +100000000000100000001000000X100000001 +1000111111111000100011111111100011111 +1000100000001000100010000000100000001 +1000100000001000100010000000100000001 +1X00100000001000100010000000100000001 +1111100010001000100010001000111110001 +1000000010000000100000001000000000001 +1000000010000000100000001000000000001 +1000000010000000100000001000000000001 +1000100011111111111111111111111111111 +1000100010000000100000000000000000001 +1000100010000000100000000000000000001 +1000100010000000100000000000000000001 +1000100010001000100011111111111110001 +1000100010001000100010000000000010001 +1000100010001000100010000000000010001 +1000100X10001000100010000000000010001 +1000111110001000100010001111111110001 +1000000000001000000010001000000000001 +1000000000001000000010001000000000001 +1000000000001000000010001000000000001 +1000111111111111111110001000111110001 +1000000000000000000010000000100000001 +1000000000000000000010000000100000001 +1000000000000000000X100000001X0000001 +1111111111111111111111111111111111111 \ No newline at end of file diff --git a/source/core/assets/minigameMaze/maze6.txt b/source/core/assets/minigameMaze/maze6.txt new file mode 100644 index 000000000..6c63faacb --- /dev/null +++ b/source/core/assets/minigameMaze/maze6.txt @@ -0,0 +1,201 @@ +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +100000001000000000000000000000000000000010000000000000000000100000000000000010000000000010000000000000000000000010000000000000000000000000001000000000000000000010000000100000001000000010000000000000001 +100000001000000000000000000000000000000010000000000000000000100000000000000010000000000010000000000000000000000010000000000000000000000000001000000000000000000010000000100000001000000010000000000000001 +100000001000000000000000000000000000000010000000000000000000100000000000000010000000000010000000000000000000000010000000000000000000000000001000000000000000000010000000100000001000000010000000000000001 +100010001000111111111000100011111111111110001111100011111000111111111111100010001111100011111000111110001111111110001000111111111111111110001111111111111000100010001111100010001000100010001111111110001 +100010000000100000001000100010000000000000000000100010001000000000000000000010000000100000001000100000001000000010001000000010000000000010000000100000000000100010000000000010000000100000000000100000001 +100010000000100000001000100010000000000000000000100010001000000000000000000010000000100000001000100000001000000010001000000010000000000010000000100000000000100010000000000010000000100000000000100000001 +100010000000100000001000100010000000000000000000100010001000000000000000000010000000100000001000100000001000000010001000000010000000000010000000100000000000100010000000000010000000100000000000100000001 +100011111111100010001000100010001111111111111111100010001111111111111000111111111000111110001111100010001000100010001111100010001111111111111000100011111111100011111111111111111111111111111000100010001 +100000001000000010001000100010001000100000000000000010000000000000000000100000000000100010000000100010001000100010001000000010000000000000001000000010000000100000000000000000000000000010000000100010001 +100000001000000010001000100010001000100000000000000010000000000000000000100000000000100010000000100010001000100010001000000010000000000000001000000010000000100000000000000000000000000010000000100010001 +100000001000000010001000100010001000100000000000000010000000000000000000100000000000100010000000100010001000100010001000000010000000000000001000000010000000100000000000000000000000000010000000100010001 +111110001000111110001000111110001000100011111111111111111111111111111000100011111111100011111000100011111000100010001000111111111111100010001111111110001111111111111111111111111111100010001111100011111 +100000001000000010001000100000000000100000000000100000001000000000001000100000001000000000001000100000000000100000001000100000000000100010000000000000001000000000000000000000000000100010001000100000001 +100000001000000010001000100000000000100000000000100000001000000000001000100000001000000000001000100000000000100000001000100000000000100010000000000000001000000000000000000000000000100010001000100000001 +100000001000000010001000100000000000100000000000100000001000000000001000100000001000000000001000100000000000100000001000100000000000100010000000000000001000000000000000000000000000100010001000100000001 +100011111111111110001000100011111111111111111000100010001000111110001000111110001000100011111000100011111111111111111000100011111000111110001111111111111000111111111000111111111111100010001000111110001 +100010000000000010001000000010000000100000001000000010000000100000001000100000001000100010000000100000000000000000001000000010001000000010001000000000000000100000001000000000000000000010000000000010001 +100010000000000010001000000010000000100000001000000010000000100000001000100000001000100010000000100000000000000000001000000010001000000010001000000000000000100000001000000000000000000010000000000010001 +100010000000000010001000000010000000100000001000000010000000100000001000100000001000100010000000100000000000000000001000000010001000000010001000000000000000100000001000000000000000000010000000000010001 +100010001111100010001111111110001000100010001000111111111111100011111000100011111000111110001111111110001111111111111111100010001111100010001000111111111111100010001111111111111111111111111000111110001 +100010000000100010000000000010001000000010001000000000001000000010001000100000001000100000001000000010001000000010000000100000000000100010001000000010000000000010000000000000000000000000000000100000001 +100010000000100010000000000010001000000010001000000000001000000010001000100000001000100000001000000010001000000010000000100000000000100010001000000010000000000010000000000000000000000000000000100000001 +100010000000100010000000000010001000000010001000000000001000000010001000100000001000100000001000000010001000000010000000100000000000100010001000000010000000000010000000000000000000000000000000100000001 +100011111000100010001111111110001111111110001000111111111000111110001000111111111000100011111000111110001000100010001000111111111111100010001111100010001111111111111111111111111111100011111111100010001 +100000000000100010001000000010000000100000001000100000001000000010000000000000001000000010000000100000001000100000001000000010000000000010000000100010001000000000001000000000000000100000000000100010001 +100000000000100010001000000010000000100000001000100000001000000010000000000000001000000010000000100000001000100000001000000010000000000010000000100010001000000000001000000000000000100000000000100010001 +100000000000100010001000000010000000100000001000100000001000000010000000000000001000000010000000100000001000100000001000000010000000000010000000100010001000000000001000000000000000100000000000100010001 +111111111111100010001000100011111000100011111111100010001111100010001111111111111000111111111000100011111000111111111111100010001111111110001000100010001000111110001000111111111000111111111000100010001 +100000000000000010000000100000001000100000000000000010000000000010000000100000001000100000000000100010000000100000001000000010000000100000001000000010001000100000001000100000001000100000001000100010001 +100000000000000010000000100000001000100000000000000010000000000010000000100000001000100000000000100010000000100000001000000010000000100000001000000010001000100000001000100000001000100000001000100010001 +10000000000000001000000010000000100010000000000000001000000000001000000010000000100010000000000010001000000010000000100000001000000010000000100000001X001000100000001000100000001000100000001000100010001 +100011111111111111111111100010001000111111111111111111111000111111111000100010001000100010001111100010001111100010001000111110001000100011111111111111111000100011111000100011111000100010001000100011111 +100000000000000000000000100010001000000000000000000010000000100000001000100010000000100010001000000010000000100010000000100000001000100010000000000000000000100010000000100000000000000010001000100000001 +100000000000000000000000100010001000000000000000000010000000100000001000100010000000100010001000000010000000100010000000100000001000100010000000000000000000100010000000100000000000000010001000100000001 +100000000000000000000000100010001000000000000000000010000000100000001000100010000000100010001000000010000000100010000000100000001000100010000000000000000000100010000000100000000000000010001000100000001 +111111111111111111111000111110001111111111111111100011111111100010001000100011111111100010001000111111111000111111111000111111111000100010001111111111111111100011111000111111111111111110001000111110001 +10000000100000000000100000001000000010000000000010000000000000001000100010001000000X100010000000100000001000100000001000100000000000100000001000100000001000000010000000100000000000100010001000100000001 +100000001000000000001000000010000000100000000000100000000000000010001000100010000000100010000000100000001000100000001000100000000000100000001000100000001000000010000000100000000000100010001000100000001 +100000001000000000001000000010000000100000000000100000000000000010001000100010000000100010000000100000001000100000001000100000000000100000001000100000001000000010000000100000000000100010001000100000001 +100010001000111111111111100010001000100010001111111111111111100010001111100010001111100011111111100010001000100010001000100011111111111111111000100010001000111110001000100011111000100010001000100010001 +100010000000100000000000100010001000000010001000000010000000100010000000100010000000000000001000000010001000000010001000000010000000000000000000100010000000100000001000100010000000100000001000100010001 +100010000000100000000000100010001000000010001000000010000000100010000000100010000000000000001000000010001000000010001000000010000000000000000000100010000000100000001000100010000000100000001000100010001 +100010000000100000000000100010001000000010001000000010000000100010000000100010000000000000001000000010001000000010001000000010000000000000000000100010000000100000001000100010000000100000001000100010001 +100011111111100010001111100010001111111110001000100010001000111111111000100011111111111111111000111110001111111110001111100011111111111111111000100011111111100010001111100010001111111110001111100010001 +100000000000000010000000000010001000000010001000100000001000000000000000100000000000000010000000100000001000000010001000000010000000000010000000100000001000000010001000000010001000000010000000000010001 +100000000000000010000000000010001000000010001000100000001000000000000000100000000000000010000000100000001000000010001000000010000000000010000000100000001000000010001000000010001000000010000000000010001 +100000000000000010000000000010001000000010001000100000001000000000000000100000000000000010000000100000001000000010001000000010000000000010000000100000001000000010001000000010001000000010000000000010001 +100011111111111111111111111110001000111110001000111111111111111111111000111111111111100010001111100011111000100010001111111110001111100010001111111110001111100010001000111110001000100011111111111110001 +100010000000000010000000000000001000100000001000100000001000000010000000000000001000100000001000100000000000100010000000100000001000000010001000000010000000100010000000100000001000100010000000000000001 +100010000000000010000000000000001000100000001000100000001000000010000000000000001000100000001000100000000000100010000000100000001000000010001000000010000000100010000000100000001000100010000000000000001 +100010000000000010000000000000001000100000001000100000001000000010000000000000001000100000001000100000000000100010000000100000001000000010001000000010000000100010000000100000001000100010000000000000001 +100011111111100010001111111110001000100011111000100010001000100011111111111110001000111111111000111111111111100010001000100011111000111110001000100011111000100011111111100011111000100011111111111111111 +10000000000010000000100000001000100000001000100000001000000010001000000000001000000000001X000000000000000000100010001000000000001000100000000000100000001000100010000000100000000000100000000000000000001 +100000000000100000001000000010001000000010001000000010000000100010000000000010000000000010000000000000000000100010001000000000001000100000000000100000001000100010000000100000000000100000000000000000001 +100000000000100000001000000010001000000010001000000010000000100010000000000010000000000010000000000000000000100010001000000000001000100000000000100000001000100010000000100000000000100000000000000000001 +111111111000100011111000100010001000111110001111111111111111100010001111100011111111100011111111111111111000100011111111111111111000111111111111111110001000100010001000111110001111111111111111111110001 +100000000000100010000000100000001000100000000000000000001000000010000000100010000000100000000000100000000000100000000000100000000000100000000000000010000000100010001000000010000000100000000000000010001 +100000000000100010000000100000001000100000000000000000001000000010000000100010000000100000000000100000000000100000000000100000000000100000000000000010000000100010001000000010000000100000000000000010001 +100000000000100010000000100000001000100000000000000000001000000010000000100010000000100000000000100000000000100000000000100000000000100000000000000010000000100010001000000010000000100000000000000010001 +100011111111111110001111111111111000111111111111100011111000111111111000100011111000111111111000100011111111111111111000100011111111100011111111100010001111111110001111100011111000100011111111100010001 +100000000000000000001000000000001000100000001000000010000000100000001000100000001000000010000000100000001000000010000000100000001000000000000000100010000000000000001000100010000000100000001000100000001 +100000000000000000001000000000001000100000001000000010000000100000001000100000001000000010000000100000001000000010000000100000001000000000000000100010000000000000001000100010000000100000001000100000001 +100000000000000000001000000000001000100000001000000010000000100000001000100000001000000010000000100000001000000010000000100000001000000000000000100010000000000000001000100010000000100000001000100000001 +111111111111111111111000100011111000100010001000111110001111100010001000111110001111100010001111111110001000100010001111100010001000111111111111100011111111111111111000100011111111111110001000111110001 +100000001000000000000000100010000000100010001000000010000000000010001000000010000000100010000000000000001000100000001000100010000000100010000000000010000000000010000000000000000000000000001000000010001 +100000001000000000000000100010000000100010001000000010000000000010001000000010000000100010000000000000001000100000001000100010000000100010000000000010000000000010000000000000000000000000001000000010001 +100000001000000000000000100010000000100010001000000010000000000010001000000010000000100010000000000000001000100000001000100010000000100010000000000010000000000010000000000000000000000000001000000010001 +100011111000111110001111111110001111100010001111100011111111111110001111100011111000100010001111111110001000111111111000100011111111100010001111111110001111100011111111111111111111111111111111100010001 +100010000000100010000000000000001000000010000000000010000000000010001000000010001000100000001000000010001000000000001000100000000000100010000000000000000000100000000000100000001000000000000000100000001 +100010000000100010000000000000001000000010000000000010000000000010001000000010001000100000001000000010001000000000001000100000000000100010000000000000000000100000000000100000001000000000000000100000001 +100010000000100010000000000000001000000010000000000010000000000010001000000010001000100000001000000010001000000000001000100000000000100010000000000000000000100000000000100000001000000000000000100000001 +100010001111100011111111111111111000111111111111111110001111100010001000111110001000111111111000100011111111111110001000111111111000100011111111111111111000111111111000100010001000111111111000111111111 +100000001000000010000000000000001000000010000000000000000000100010001000100000001000000000000000100000000000100010001000000010000000100010000000000010001000100000001000000010001000100000001000000000001 +100000001000000010000000000000001000000010000000000000000000100010001000100000001000000000000000100000000000100010001000000010000000100010000000000010001000100000001000000010001000100000001000000000001 +100000001000000010000000000000001000000010000000000000000000100010001000100000001000000000000000100000000000100010001000000010000000100010000000000010001000100000001000000010001000100000001000000000001 +100011111000100010001111100011111000100010001111111111111111100010001000100010001111111111111111111110001000100010001111100010001111100010001111100010001000100011111111111110001000100010001111111110001 +100010000000100010001000100000000000100000001000000000001000000010000000100010001000000010000000000000001000000010000000100010001000000010000000100010000000100000000000000010001000000010000000100000001 +100010000000100010001000100000000000100000001000000000001000000010000000100010001000000010000000000000001000000010000000100010001000000010000000100010000000100000000000000010001000000010000000100000001 +100010000000100010001000100000000000100000001000000000001000000010000000100010001000000010000000000000001000000010000000100010001000000010000000100010000000100000000000000010001000000010000000100000001 +100010001111111110001000111111111111111111111000111110001000111111111111100011111000100010001111111111111111100011111000100010001111100011111000100010001111111110001111100010001000111111111111100010001 +100010000000000010000000000000001000000000001000000010001000000000000000000010000000100010000000000010000000100010000000100000001000000000001000100010000000000000001000000010000000100000001000000010001 +100010000000000010000000000000001000000000001000000010001000000000000000000010000000100010000000000010000000100010000000100000001000000000001000100010000000000000001000000010000000100000001000000010001 +100010000000000010000000000000001000000000001000000010001000000000000000000010000000100010000000000010000000100010000000100000001000000000001000100010000000000000001000000010000000100000001000000010001 +100011111111100011111111111110001111100010001000100010001111111110001111111110001111100011111111100010001111100010001111100011111000111111111000100011111000111111111000111111111111100010001000111110001 +100000000000100000000000100000001000000010001000100010000000100000001000000000001000000000001000000010000000100010001000000010000000100000001000100000001000100000001000000000000000100010001000100000001 +100000000000100000000000100000001000000010001000100010000000100000001000000000001000000000001000000010000000100010001000000010000000100000001000100000001000100000001000000000000000100010001000100000001 +100000000000100000000000100000001000000010001000100010000000100000001000000000001000000000001000000010000000100010001000000010000000100000001000100000001000100000001000000000000000100010001000100000001 +111111111000100011111000100011111000111110001111100010001111100010001000111111111000111110001000111110001000100010001000111110001000100010001000111110001000100010001111111110001111100010001000100011111 +100010000000100000001000100010000000100000000000000010001000000010001000000010000000100000001000000010001000000010001000100000001000100010000000100010001000100010000000100000001000000010001000100000001 +100010000000100000001000100010000000100000000000000010001000000010001000000010000000100000001000000010001000000010001000100000001000100010000000100010001000100010000000100000001000000010001000100000001 +100010000000100000001000100010000000100000000000000010001000000010001000000010000000100000001000000010001000000010001000100000001000100010000000100010001000100010000000100000001000000010001000100000001 +100010001111111110001000100011111000111111111000111111111000111111111000111110001111100011111111100011111111111110001000100010001111100011111111100010001111100011111000100011111000111110001000111110001 +100010001000000000001000100000001000100000001000100000000000100000000000100000001000000000000000100000001000000000001000100010001000000010001000000010000000100010000000100000001000100010001000000010001 +100010001000000000001000100000001000100000001000100000000000100000000000100000001000000000000000100000001000000000001000100010001000000010001000000010000000100010000000100000001000100010001000000010001 +100010001000000000001000100000001000100000001000100000000000100000000000100000001000000000000000100000001000000000001000100010001000000010001000000010000000100010000000100000001000100010001000000010001 +100010001000111111111000111110001000100010001111100011111111100011111111100011111111111111111111111110001000111111111000100010001000111110001000100011111000100011111000111111111000100010001111100010001 +100000001000100000001000000010000000100010000000100000001000000010000000100000000000000000000000000010000000100000001000000010001000100000000000100000001000100000001000000000000000100000001000000010001 +100000001000100000001000000010000000100010000000100000001000000010000000100000000000000000000000000010000000100000001000000010001000100000000000100000001000100000001000000000000000100000001000000010001 +100000001000100000001000000010000000100010000000100000001000000010000000100000000000000000000000000010000000100000001000000010001000100000000000100000001000100000001000000000000000100000001000000010001 +100011111000100010001111100011111000100011111000111110001000111110001000111111111111111111111000100011111111100011111111100011111000111111111111100010001000100010001111111111111111100011111000111110001 +100000001000000010000000100000000000100000001000000000001000000000001000000000000000100000000000100000000000000010000000000010000000100000000000100010001000100010001000000000000000100010000000100000001 +100000001000000010000000100000000000100000001000000000001000000000001000000000000000100000000000100000000000000010000000000010000000100000000000100010001000100010001000000000000000100010000000100000001 +100000001000000010000000100000000000100000001000000000001000000000001000000000000000100000000000100000000000000010000000000010000000100000000000100010001000100010001000000000000000100010000000100000001 +111110001111111111111000111111111111111110001111111111111111111111111111111111111000100011111111111111111000111110001111111110001111100011111000100011111000100010001111100011111000100010001000100011111 +100010000000100000000000100000001000000010000000000000000000100000000000000000000000100000000000100000001000100000001000000000001000000010001000100010000000100010000000100010001000000010001000100000001 +100010000000100000000000100000001000000010000000000000000000100000000000000000000000100000000000100000001000100000001000000000001000000010001000100010000000100010000000100010001000000010001000100000001 +100010000000100000000000100000001000000010000000000000000000100000000000000000000000100000000000100000001000100000001000000000001000000010001000100010000000100010000000100010001000000010001000100000001 +100011111000100011111111111110001000100011111111111110001000100011111111111111111111111111111000100010001111100011111000111111111000111110001000100010001111111111111000100010001111111110001000111111111 +100000001000100000000000000010001000100000001000100000001000100010000000000010000000000000001000100010000000100010001000000000000000000000001000100010000000000000000000100000000000000010001000000000001 +100000001000100000000000000010001000100000001000100000001000100010000000000010000000000000001000100010000000100010001000000000000000000000001000100010000000000000000000100000000000000010001000000000001 +100000001000100000000000000010001000100000001000100000001000100010000000000010000000000000001000100010000000100010001000000000000000000000001000100010000000000000000000100000000000000010001000000000001 +100011111000111111111111100010001000100010001000100011111111100011111111100010001111111110001000100011111000100010001111111111111111111111111000100011111111111111111111111111111111100011111111111110001 +100000001000100000000000100010000000100010001000100000000000100000000000100010001000000000000000100010000000100000000000000010000000000000000000100010000000000010000000000000000000100000000000000000001 +100000001000100000000000100010000000100010001000100000000000100000000000100010001000000000000000100010000000100000000000000010000000000000000000100010000000000010000000000000000000100000000000000000001 +100000001000100000000000100010000000100010001000100000000000100000000000100010001000000000000000100010000000100000000000000010000000000000000000100010000000000010000000000000000000100000000000000000001 +100010001000111110001111100011111111100010001000111111111000111111111000100010001000111111111111100010001111111110001111111110001111111111111111100010001000100010001000111111111111111111111111111110001 +100010001000000010000000000000000000100010001000000000001000100000001000000010001000000010000000000010000000000010001000000010000000100000001000000000001000100000001000100000001000000000001000000010001 +100010001000000010000000000000000000100010001000000000001000100000001000000010001000000010000000000010000000000010001000000010000000100000001000000000001000100000001000100000001000000000001000000010001 +100010001000000010000000000000000000100010001000000000001000100000001000000010001000000010000000000010000000000010001000000010000000100000001000000000001000100000001000100000001000000000001000000010001 +111110001111100011111111111111111000100010001111111110001000100010001111100010001111111110001111111111111111100010001000100011111000100010001000111111111000111111111111100010001000100011111000100010001 +100000000000100000001000000010000000000010000000000000001000000010000000000010000000000010001000000000001000000010001000100000001000100010001000100010000000100000001000000010000000100000000000100010001 +100000000000100000001000000010000000000010000000000000001000000010000000000010000000000010001000000000001000000010001000100000001000100010001000100010000000100000001000000010000000100000000000100010001 +100000000000100000001000000010000000000010000000000000001000000010000000000010000000000010001000000000001000000010001000100000001000100010001000100010000000100000001000000010000000100000000000100010001 +100011111111111110001000100011111111111111111111111110001111111111111111111111111111100010001111100010001000111110001000111110001000100010001000100010001111100010001000111111111111111111111111100010001 +10000000000000001000000010000000000000000000100000000000100000000000000000001000000X100000000000000010001000100000001000100010000000100010000000100010000000000010000000100000000000100000000000100000001 +100000000000000010000000100000000000000000001000000000001000000000000000000010000000100000000000000010001000100000001000100010000000100010000000100010000000000010000000100000000000100000000000100000001 +100000000000000010000000100000000000000000001000000000001000000000000000000010000000100000000000000010001000100000001000100010000000100010000000100010000000000010000000100000000000100000000000100000001 +100011111000111111111111111111111111111110001111100011111111111110001111100010001111111111111111111110001000100011111000100011111111100011111111100011111111111111111111111110001000100011111000111111111 +100010000000100000000000000010000000000010000000100010000000100000001000100010000000100000000000000010001000000010000000100000000000100010000000000000000000000010000000000000001000000010000000000000001 +100010000000100000000000000010000000000010000000100010000000100000001000100010000000100000000000000010001000000010000000100000000000100010000000000000000000000010000000000000001000000010000000000000001 +100010000000100000000000000010000000000010000000100010000000100000001000100010000000100000000000000010001000000010000000100000000000100010000000000000000000000010000000000000001000000010000000000000001 +111110001000100011111000100011111111100011111000100010001000100011111000100011111000100011111111100010001111111110001111100010001111100010001111111110001111111110001111100011111111111111111111111110001 +100000001000100010001000100000000000000000001000100000001000100010000000000000000000100010000000000010000000000010001000100010000000000010000000000010001000000000001000100000001000000010000000100000001 +100000001000100010001000100000000000000000001000100000001000100010000000000000000000100010000000000010000000000010001000100010000000000010000000000010001000000000001000100000001000000010000000100000001 +100000001000100010001000100000000000000000001000100000001000100010000000000000000000100010000000000010000000000010001000100010000000000010000000000010001000000000001000100000001000000010000000100000001 +100011111000100010001000111111111111111111111000111111111000100010001111111111111000100011111000111111111111100010001000100011111111111111111000111110001000111111111000111110001000100010001000100011111 +100010000000100000001000000000000000000000000000100000001000100010001000000000001000100000001000100000001000000010001000000000000000100000000000100000001000000000000000100010000000100000001000100000001 +100010000000100000001000000000000000000000000000100000001000100010001000000000001000100000001000100000001000000010001000000000000000100000000000100000001000000000000000100010000000100000001000100000001 +100010000000100000001000000000000000000000000000100000001000100010001000000000001000100000001000100000001000000010001000000000000000100000000000100000001000000000000000100010000000100000001000100000001 +100010001111111110001111111111111111111111111111100011111000100011111000111110001111111110001000100010001111111110001111111111111000111110001111100010001111111111111000100011111111111110001000111110001 +100010001000000000001000000000000000000000001000000000000000100000001000100010000000100000001000000010000000000010000000100000001000000010001000100010000000000010000000000000001000000010001000100000001 +100010001000000000001000000000000000000000001000000000000000100000001000100010000000100000001000000010000000000010000000100000001000000010001000100010000000000010000000000000001000000010001000100000001 +100010001000000000001000000000000000000000001000000000000000100000001000100010000000100000001000000010000000000010000000100000001000000010001000100010000000000010000000000000001000000010001000100000001 +100011111000111111111111111110001111111110001111100011111111111110001000100011111000100011111111111111111111100011111000111110001111100010001000100011111111100010001111111111111000100011111000100011111 +100000000000100000000000000000001000000010000000100000000000000010001000100000001000000010000000000000001000100000000000100000000000100010000000100000001000000010001000000000000000100000001000100010001 +100000000000100000000000000000001000000010000000100000000000000010001000100000001000000010000000000000001000100000000000100000000000100010000000100000001000000010001000000000000000100000001000100010001 +100000000000100000000000000000001000000010000000100000000000000010001000100000001000000010000000000000001000100000000000100000000000100010000000100000001000000010001000000000000000100000001000100010001 +100011111111100010001111111111111000100011111000111111111111100010001000100010001111111110001111111110001000111111111111100011111000100011111000111110001111111110001000111111111111111110001000100010001 +100010000000100010000000000000000000100000001000000000001000000010001000100010000000100000000000100000001000000000000000000010001000100000001000000010001000000010001000000010000000000010000000100000001 +100010000000100010000000000000000000100000001000000000001000000010001000100010000000100000000000100000001000000000000000000010001000100000001000000010001000000010001000000010000000000010000000100000001 +100010000000100010000000000000000000100000001000000000001000000010001000100010000000100000000000100000001000000000000000000010001000100000001000000010001000000010001000000010000000000010000000100000001 +100010001000100011111111100011111111111110001111111110001111100010001000111110001000100011111000100011111111111110001111111110001000111110001111100010001000100010001111100010001000100011111111111110001 +100010001000000010000000100000000000000010000000100010000000100000001000000010001000100010000000100000000000000000001000000010000000100010001000000010000000100000000000100010001000100010000000000000001 +100010001000000010000000100000000000000010000000100010000000100000001000000010001000100010000000100000000000000000001000000010000000100010001000000010000000100000000000100010001000100010000000000000001 +100010001000000010000000100000000000000010000000100010000000100000001000000010001000100010000000100000000000000000001000000010000000100010001X00000010000000100000000000100010001000100010000000000000001 +100011111111100010001000111111111111100011111000100011111000111110001111100010001111100010001111111111111111111111111000100010001111100010001111111111111111111111111111100010001000100010001111111111111 +100000000000100010001000000000000000100000001000100000001000000010001000000010001000000010000000000000001000000010000000100000001000000010000000000000001000000000000000000010001000100010001000000000001 +100000000000100010001000000000000000100000001000100000001000000010001000000010001000000010000000000000001000000010000000100000001000000010000000000000001000000000000000000010001000100010001000000000001 +100000000000100010001000000000000000100000001000100000001000000010001000000010001000000010000000000000001000000010000000100000001000000010000000000000001000000000000000000010001000100010001000000000001 +111111111000111110001111111111111000111111111000111110001111100011111000111110001000111111111111111110001000100011111111111110001111100011111111111110001000111111111111111110001000111110001000111110001 +100000001000000010000000100010000000100000001000000010000000000010000000100000000000000000001000000010000000100000001000000010000000000000000000000010000000100010000000000010001000000010001000100000001 +100000001000000010000000100010000000100000001000000010000000000010000000100000000000000000001000000010000000100000001000000010000000000000000000000010000000100010000000000010001000000010001000100000001 +100000001000000010000000100010000000100000001000000010000000000010000000100000000000000000001000000010000000100000001000000010000000000000000000000X10000000100010000000000010001000000010001000100000001 +100011111111100011111000100010001111100010001111100010001111111110001111100011111111111110001000111111111111111110001000100011111111111111111111111111111111100010001000111110001111100010001111100010001 +100000000000100000000000100000001000000010000000000010000000000010001000000010000000000010001000000000000000000010000000100000000000000010000000000000000000000010001000000000001000000010000000000010001 +100000000000100000000000100000001000000010000000000010000000000010001000000010000000000010001000000000000000000010000000100000000000000010000000000000000000000010001000000000001000000010000000000010001 +100000000000100000000000100000001000000010000000000010000000000010001000000010000000000010001000000000000000000010000000100000000000000010000000000000000000000010001000000000001000000010000000000010001 +100011111000111111111111100011111000111111111111111111111111100010001111111110001111100010001000100011111111100011111111111111111111100010001111111111111000111110001111111111111000111111111111111110001 +100010001000000000000000100000000000100000000000000000001000000010000000000000001000000010001000100000001000000010000000000000001000100000001000000000000000100000001000000000001000100000000000100010001 +100010001000000000000000100000000000100000000000000000001000000010000000000000001000000010001000100000001000000010000000000000001000100000001000000000000000100000001000000000001000100000000000100010001 +100010001000000000000000100000000000100000000000000000001000000010000000000000001000000010001000100000001000000010000000000000001000100000001000000000000000100000001000000000001000100000000000100010001 +100010001000111111111111111111111111100011111111111110001000111111111111100011111000111110001000111110001000111111111000111110001000111111111000111111111111100011111111100010001000100010001000100010001 +100000001000100000000000000000000000100010001000000000001000000000000000100010001000000010001000100000001000000000000000100000001000000000001000000000000000000010000000000010001000000010001000000010001 +100000001000100000000000000000000000100010001000000000001000000000000000100010001000000010001000100000001000000000000000100000001000000000001000000000000000000010000000000010001000000010001000000010001 +100000001000100000000000000000000000100010001000000000001000000000000000100010001000000010001000100000001000000000000000100000001000000000001000000000000000000010000000000010001000000010001000000010001 +111110001000100011111111111111111000100010001000111111111111111111111000100010001111100010001111100011111111111111111111100011111000111110001111111111111111111110001000111111111111111110001111111110001 +100000001000100010001000000010000000100000001000000000000000000000001000100000001000100010000000000010000000100000000000100010000000100000000000000010000000000000001000000000000000000010000000000010001 +100000001000100010001000000010000000100000001000000000000000000000001000100000001000100010000000000010000000100000000000100010000000100000000000000010000000000000001000000000000000000010000000000010001 +100000001000100010001000000010000000100000001000000000000000000000001000100000001000100010000000000010000000100000000000100010000000100000000000000010000000000000001000000000000000000010000000000010001 +100011111000100010001000100010001111111110001111111111111000111111111000111110001000100011111111111110001111100011111000100010001111100011111111100010001111111111111111111111111000100011111111100010001 +100010001000000010001000100000001000000010000000100000001000000000001000100010000000100010000000000010001000000000001000100010001000000010000000100010000000100000000000100000000000100000001000000010001 +100010001000000010001000100000001000000010000000100000001000000000001000100010000000100010000000000010001000000000001000100010001000000010000000100010000000100000000000100000000000100000001000000010001 +100010001000000010001000100000001000000010000000100000001000000000001000100010000000100010000000000010001000000000001000100010001000000010000000100010000000100000000000100000000000100000001000000010001 +100010001111111110001000111111111000100011111000100010001111111110001000100011111000100010001111100010001000111111111000100011111000111110001111100010001111100011111000100011111111100011111000100010001 +100000000000100000001000100000000000100000001000000010000000000010000000100000000000100010000000100000001000100010000000100000001000000010000000100010001000000010001000000010000000100010000000100010001 +100000000000100000001000100000000000100000001000000010000000000010000000100000000000100010000000100000001000100010000000100000001000000010000000100010001000000010001000000010000000100010000000100010001 +10000000000010000000100010000000000010000000100000001000000000001000000010000000000010001000000010000000100010001000000010000000100000001000000010001X001000000010001000000010000000100010000000100010001 +111111111000100010001000100011111111111110001111111111111111100011111111111111111111100010001000111110001000100010001111111110001111100011111000100011111000111110001111100010001000111110001111100010001 +100000000000100010001000000010000000000010000000000010000000000010000000000010000000000010001000000010001000000010000000000000001000000010000000100000001000000010000000000010001000000000001000000010001 +100000000000100010001000000010000000000010000000000010000000000010000000000010000000000010001000000010001000000010000000000000001000000010000000100000001000000010000000000010001000000000001000000010001 +100000000000100010001000000010000000000010000000000010000000000010000000000010000000000010001000000010001000000010000000000000001000000010000000100000001000000010000000000010001000000000001000000010001 +100011111111100011111111111111111000100010001111100010001111111110001111100010001111111111111000100011111111100011111111111111111000111110001111111110001111100010001111111110001000111111111111111110001 +100010000000100000000000100000000000100010000000100010001000000000001000000010000000000000001000100000000000000010000000100000000000100010000000000010001000000010001000000010001000100000001000000010001 +100010000000100000000000100000000000100010000000100010001000000000001000000010000000000000001000100000000000000010000000100000000000100010000000000010001000000010001000000010001000100000001000000010001 +100010000000100000000000100000000000100010000000100010001000000000001000000010000000000000001000100000000000000010000000100000000000100010000000000010001000000010001000000010001000100000001000000010001 +100010001000111110001000100011111111100011111000111110001111100011111000111111111111111110001000111111111111111110001000100011111111100010001000111110001000111110001000100010001111100010001000100010001 +100000001000000000001000000010000000000000001000000000000000000010000000000000000000000000001000000000000000000000001000000010000000000000001000000000000000100000000000100010000000000010000000100000001 +100000001000000000001000000010000000000000001000000000000000000010000000000000000000000000001000000000000000000000001000000010000000000000001000000000000000100000000000100010000000000010000000100000001 +10000000100000000000100000001X000000000000001000000000000000000010000000000000000000000000001000000000000000000000001000000010000000000000001000000000000000100000000000100010000000000010000000100000001 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 \ No newline at end of file diff --git a/source/core/src/main/com/csse3200/game/components/minigames/maze/MazeAssetPaths.java b/source/core/src/main/com/csse3200/game/components/minigames/maze/MazeAssetPaths.java index 0e4663d9c..d24b8624f 100644 --- a/source/core/src/main/com/csse3200/game/components/minigames/maze/MazeAssetPaths.java +++ b/source/core/src/main/com/csse3200/game/components/minigames/maze/MazeAssetPaths.java @@ -6,6 +6,9 @@ public class MazeAssetPaths { public static final String TEST_MAZE = "minigameMaze/TestMaze.txt"; public static final String MAZE_ONE = "minigameMaze/MazeOne.txt"; public static final String MAZE_TWO = "minigameMaze/maze2.txt"; + public static final String MAZE_THREE = "minigameMaze/expanded_maze.txt"; + public static final String MAZE_FIVE = "minigameMaze/maze5.txt"; + public static final String MAZE_SIX = "minigameMaze/maze6.txt"; // Images public static final String WATER = "images/minigames/water.png"; diff --git a/source/core/src/main/com/csse3200/game/components/minigames/maze/MazeGame.java b/source/core/src/main/com/csse3200/game/components/minigames/maze/MazeGame.java index d987d486b..8924a12f2 100644 --- a/source/core/src/main/com/csse3200/game/components/minigames/maze/MazeGame.java +++ b/source/core/src/main/com/csse3200/game/components/minigames/maze/MazeGame.java @@ -12,7 +12,7 @@ public class MazeGame { private final MinigameRenderer renderer; public MazeGame() { - this.grid = new MazeGrid(31, MazeAssetPaths.MAZE_TWO); + this.grid = new MazeGrid(201, MazeAssetPaths.MAZE_SIX); this.renderer = new MinigameRenderer(); initRenderers(); } diff --git a/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/MazeGrid.java b/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/MazeGrid.java index 3fbfda743..9c652b267 100644 --- a/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/MazeGrid.java +++ b/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/MazeGrid.java @@ -80,7 +80,7 @@ private void createMaze() { char ch = line.charAt(col); // Calculate the position for this cell float x = gridX + col * cellSize; - float y = gridY + (size - row - 1) * cellSize; // Correctly calculate the Y position + float y = gridY + (size - row - 1) * cellSize; System.out.println(new Vector2(x,y)); if (ch == '1') { From ba11df7b40c7dfcc050e7a14c207291340c0b16d Mon Sep 17 00:00:00 2001 From: James King Date: Mon, 16 Sep 2024 20:26:07 +1000 Subject: [PATCH 08/19] Add random maze generation and bfs logic --- source/core/assets/images/minigames/spawn.png | Bin 0 -> 150 bytes .../game/components/minigames/Direction.java | 18 +- .../minigames/maze/MazeAssetPaths.java | 1 + .../components/minigames/maze/MazeGame.java | 2 +- .../minigames/maze/mazegrid/MazeGrid.java | 169 ++++++++++++++++-- .../minigames/maze/mazegrid/Spawn.java | 7 + .../maze/rendering/MazeGridRenderer.java | 13 +- 7 files changed, 185 insertions(+), 25 deletions(-) create mode 100644 source/core/assets/images/minigames/spawn.png create mode 100644 source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/Spawn.java diff --git a/source/core/assets/images/minigames/spawn.png b/source/core/assets/images/minigames/spawn.png new file mode 100644 index 0000000000000000000000000000000000000000..5efebb51e2f578da2c583b3ccd18fb416316f972 GIT binary patch literal 150 zcmeAS@N?(olHy`uVBq!ia0vp^DIm!lvI6FVdQ&MBb@05QWQRR910 literal 0 HcmV?d00001 diff --git a/source/core/src/main/com/csse3200/game/components/minigames/Direction.java b/source/core/src/main/com/csse3200/game/components/minigames/Direction.java index d49bf03dc..f1650c5bc 100644 --- a/source/core/src/main/com/csse3200/game/components/minigames/Direction.java +++ b/source/core/src/main/com/csse3200/game/components/minigames/Direction.java @@ -2,9 +2,17 @@ /** Enum representing the 4 cardinal directions or no direction */ public enum Direction { - RIGHT, - LEFT, - UP, - DOWN, - ZERO + RIGHT(1,0), + LEFT(-1,0), + UP(0,1), + DOWN(0,-1), + ZERO(0,0); + + public final int dx; + public final int dy; + + Direction(int dx, int dy) { + this.dx = dx; + this.dy = dy; + } } diff --git a/source/core/src/main/com/csse3200/game/components/minigames/maze/MazeAssetPaths.java b/source/core/src/main/com/csse3200/game/components/minigames/maze/MazeAssetPaths.java index d24b8624f..57ba30a1a 100644 --- a/source/core/src/main/com/csse3200/game/components/minigames/maze/MazeAssetPaths.java +++ b/source/core/src/main/com/csse3200/game/components/minigames/maze/MazeAssetPaths.java @@ -13,6 +13,7 @@ public class MazeAssetPaths { // Images public static final String WATER = "images/minigames/water.png"; public static final String WALL = "images/minigames/wall.png"; + public static final String SPAWN = "images/minigames/spawn.png"; private MazeAssetPaths() { diff --git a/source/core/src/main/com/csse3200/game/components/minigames/maze/MazeGame.java b/source/core/src/main/com/csse3200/game/components/minigames/maze/MazeGame.java index 8924a12f2..52f03ad8a 100644 --- a/source/core/src/main/com/csse3200/game/components/minigames/maze/MazeGame.java +++ b/source/core/src/main/com/csse3200/game/components/minigames/maze/MazeGame.java @@ -12,7 +12,7 @@ public class MazeGame { private final MinigameRenderer renderer; public MazeGame() { - this.grid = new MazeGrid(201, MazeAssetPaths.MAZE_SIX); + this.grid = new MazeGrid(9, 3); this.renderer = new MinigameRenderer(); initRenderers(); } diff --git a/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/MazeGrid.java b/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/MazeGrid.java index 9c652b267..16d82d290 100644 --- a/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/MazeGrid.java +++ b/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/MazeGrid.java @@ -2,9 +2,11 @@ import com.badlogic.gdx.Gdx; import com.badlogic.gdx.files.FileHandle; -import com.badlogic.gdx.math.Vector2; +import com.csse3200.game.components.minigames.Direction; +import com.csse3200.game.components.minigames.GridCell; import java.io.*; +import java.util.*; /** * Represents a maze grid that is created from a file. @@ -13,10 +15,7 @@ * NotWall. */ public class MazeGrid{ - - - private final String file; // File path to the maze - private final int size; // Size of the grid + private final int size; private final MazeCell[][] cells; // 2D array representing the cells // Screen size @@ -38,11 +37,16 @@ public class MazeGrid{ */ public MazeGrid(int size, String file) { this.size = size; - this.file = file; this.cells = new MazeCell[size][size]; calculateCellDimensions(); - createMaze(); + readMazeFromFile(file); + } + public MazeGrid(int size, int pathingSize) { + this.size = size * (pathingSize + 1) + 1; + this.cells = new MazeCell[this.size][this.size]; + calculateCellDimensions(); + generateRandomMaze(pathingSize, 5); } private void calculateCellDimensions() { @@ -65,11 +69,147 @@ public MazeCell[][] getMaze() { return cells; } + /** + * Constructs a random maze using a recursive backtracking maze generator algorithm. + * Assumes maze has not been generated or read from a file previously. + */ + private void generateRandomMaze(int pathingSize, int numSpawns) { + Random rand = new Random(); + int r = rand.nextInt(size/(pathingSize+1) - 1) * (pathingSize+1) + 1; + int c = rand.nextInt(size/(pathingSize+1) - 1) * (pathingSize+1) + 1; + + recursiveBacktracking(r, c, pathingSize, rand); + + for (int i = 0; i < size; i++) { + for (int j = 0; j < size; j++) { + if (cells[i][j] == null) { + createCellAtRowCol(i, j, Wall::new); + } + } + } + + List spanningTree = new ArrayList<>(); + spanningTree.add(new GridCell(c, r)); + + for (int i = 0; i < numSpawns; i++) { + BFS bfs = new BFS(spanningTree); + GridCell mostDistant = bfs.getMostDistant(); + createCellAtRowCol(mostDistant.getY(), mostDistant.getX(), Spawn::new); + List path = bfs.getShortestPath(bfs.getMostDistant()); + for (int cell = 1; cell < path.size(); cell++) { + spanningTree.add(path.get(cell)); + } + } + } + + private boolean notInBounds(int r, int c) { + return r < 0 || r >= size || c < 0 || c >= size; + } + + @FunctionalInterface + interface CellConstructor{ + MazeCell construct(float x, float y, float cellSize); + } + private void createCellAtRowCol(int r, int c, CellConstructor constructor) { + float x = gridX + c * cellSize; + float y = gridY + (size - r - 1) * cellSize; + cells[r][c] = constructor.construct(x, y, cellSize); + } + + private void recursiveBacktracking(int r, int c, int pathingSize, Random rand) { + System.out.println(String.valueOf(r) + ", " + String.valueOf(c)); + for (int i = 0; i < pathingSize; i++) { + for (int j = 0; j < pathingSize; j++) { + createCellAtRowCol(r+i, c+j, Water::new); + } + } + List directions = Arrays.asList(Direction.UP, Direction.DOWN, Direction.LEFT, Direction.RIGHT); + Collections.shuffle(directions, rand); + + for (Direction d : directions) { + int nr = r + d.dy * (pathingSize+1); + int nc = c + d.dx * (pathingSize+1); + if (notInBounds(nr, nc) || cells[nr][nc] != null) { + continue; + } + for (int i = 0; i < pathingSize; i++) { + switch (d) { + case UP: + createCellAtRowCol(r+pathingSize, c+i, Water::new); + break; + case DOWN: + createCellAtRowCol(r-1, c+i, Water::new); + break; + case RIGHT: + createCellAtRowCol(r+i, c+pathingSize, Water::new); + break; + case LEFT: + createCellAtRowCol(r+i, c-1, Water::new); + break; + } + } + recursiveBacktracking(nr, nc, pathingSize, rand); + } + } + + class BFS { + int[][] distances; + GridCell[][] previous; + + GridCell mostDistant; + static final Direction[] directions = {Direction.UP, Direction.DOWN, Direction.LEFT, Direction.RIGHT}; + + BFS(List startCells) { + distances = new int[size][size]; + previous = new GridCell[size][size]; + for (int r = 0; r < size; r++) { + for (int c = 0; c < size; c++) { + distances[r][c] = size*size; + } + } + for (GridCell cell: startCells) { + distances[cell.getY()][cell.getX()] = 0; + } + Queue queue = new ArrayDeque<>(startCells); + GridCell cell = null; + while (!queue.isEmpty()) { + cell = queue.remove(); + for (Direction d : directions) { + int nr = cell.getY() + d.dy; + int nc = cell.getX() + d.dx; + int dst = distances[cell.getY()][cell.getX()] + 1; + if (notInBounds(nr, nc) || distances[nr][nc] <= dst || cells[nr][nc] instanceof Wall) { + continue; + } + distances[nr][nc] = dst; + previous[nr][nc] = cell; + queue.add(new GridCell(nc, nr)); + } + } + mostDistant = cell; + } + + List getShortestPath(GridCell end) { + List path = new ArrayList<>(); + while (end != null) { + path.add(end); + end = previous[end.getY()][end.getX()]; + } + return path.reversed(); + } + + GridCell getMostDistant() { + return mostDistant; + } + } + /** * Reads the file and constructs the maze by filling the cells array. * Each character in the file is read, where '1' corresponds to a Wall and '0' to a NotWall. + * + * @param file The file path to the maze text file. */ - private void createMaze() { + private void readMazeFromFile(String file) { if (isLibGDXEnvironemnt()) { FileHandle fileHandle = Gdx.files.internal(file); // Use Gdx.files to load the file String[] lines = fileHandle.readString().split("\n"); // Read the file content @@ -78,20 +218,15 @@ private void createMaze() { String line = lines[row]; for (int col = 0; col < line.length() && col < size; col++) { char ch = line.charAt(col); - // Calculate the position for this cell - float x = gridX + col * cellSize; - float y = gridY + (size - row - 1) * cellSize; - System.out.println(new Vector2(x,y)); - if (ch == '1') { - cells[row][col] = new Wall(x, y, cellSize); + createCellAtRowCol(row, col, Wall::new); } else { - cells[row][col] = new Water(x, y, cellSize); + createCellAtRowCol(row, col, Water::new); } } } } else { - setUpInTest(); + setUpInTest(file); } } @@ -103,7 +238,7 @@ private boolean isLibGDXEnvironemnt() { return Gdx.files != null; } - private void setUpInTest() { + private void setUpInTest(String file) { try { BufferedReader br = new BufferedReader(new FileReader(file)); String line; diff --git a/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/Spawn.java b/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/Spawn.java new file mode 100644 index 000000000..03dbd78ce --- /dev/null +++ b/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/Spawn.java @@ -0,0 +1,7 @@ +package com.csse3200.game.components.minigames.maze.mazegrid; + +public class Spawn extends MazeCell{ + public Spawn(float x, float y, float size) { + super(x, y, size); + } +} diff --git a/source/core/src/main/com/csse3200/game/components/minigames/maze/rendering/MazeGridRenderer.java b/source/core/src/main/com/csse3200/game/components/minigames/maze/rendering/MazeGridRenderer.java index 6ee1b8548..3ed51045f 100644 --- a/source/core/src/main/com/csse3200/game/components/minigames/maze/rendering/MazeGridRenderer.java +++ b/source/core/src/main/com/csse3200/game/components/minigames/maze/rendering/MazeGridRenderer.java @@ -6,6 +6,7 @@ import com.csse3200.game.components.minigames.maze.MazeAssetPaths; import com.csse3200.game.components.minigames.maze.mazegrid.MazeCell; import com.csse3200.game.components.minigames.maze.mazegrid.MazeGrid; +import com.csse3200.game.components.minigames.maze.mazegrid.Spawn; import com.csse3200.game.components.minigames.maze.mazegrid.Wall; import com.csse3200.game.services.ResourceService; import com.csse3200.game.services.ServiceLocator; @@ -16,6 +17,7 @@ public class MazeGridRenderer implements MinigameRenderable { private final MinigameRenderer renderer; private Texture waterTexture; private Texture wallTexture; + private Texture spawnTexture; @@ -36,6 +38,11 @@ public void render() { cell.getPosition().y, cell.getSize(), cell.getSize()); + } else if (cell instanceof Spawn) { + renderer.getSb().draw(spawnTexture,cell.getPosition().x, + cell.getPosition().y, + cell.getSize(), + cell.getSize()); } else { renderer.getSb().draw(waterTexture,cell.getPosition().x, cell.getPosition().y, @@ -52,10 +59,11 @@ public void render() { */ private void loadAssets() { ResourceService rs = ServiceLocator.getResourceService(); - rs.loadTextures(new String[]{MazeAssetPaths.WATER, MazeAssetPaths.WALL}); + rs.loadTextures(new String[]{MazeAssetPaths.WATER, MazeAssetPaths.WALL, MazeAssetPaths.SPAWN}); ServiceLocator.getResourceService().loadAll(); waterTexture = rs.getAsset(MazeAssetPaths.WATER, Texture.class); wallTexture = rs.getAsset(MazeAssetPaths.WALL, Texture.class); + spawnTexture = rs.getAsset(MazeAssetPaths.SPAWN, Texture.class); } /** @@ -63,7 +71,7 @@ private void loadAssets() { */ private void unloadAssets() { ResourceService rs = ServiceLocator.getResourceService(); - rs.unloadAssets(new String[]{MazeAssetPaths.WATER, MazeAssetPaths.WALL}); + rs.unloadAssets(new String[]{MazeAssetPaths.WATER, MazeAssetPaths.WALL, MazeAssetPaths.SPAWN}); } /** @@ -73,5 +81,6 @@ public void dispose() { unloadAssets(); waterTexture.dispose(); wallTexture.dispose(); + spawnTexture.dispose(); } } From 51e5d938d3706f1cda9d2e5beaac700d18566d63 Mon Sep 17 00:00:00 2001 From: James King Date: Mon, 16 Sep 2024 20:30:43 +1000 Subject: [PATCH 09/19] remove useless print statement --- .../game/components/minigames/maze/mazegrid/MazeGrid.java | 1 - 1 file changed, 1 deletion(-) diff --git a/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/MazeGrid.java b/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/MazeGrid.java index 16d82d290..6a1c5a34e 100644 --- a/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/MazeGrid.java +++ b/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/MazeGrid.java @@ -117,7 +117,6 @@ private void createCellAtRowCol(int r, int c, CellConstructor constructor) { } private void recursiveBacktracking(int r, int c, int pathingSize, Random rand) { - System.out.println(String.valueOf(r) + ", " + String.valueOf(c)); for (int i = 0; i < pathingSize; i++) { for (int j = 0; j < pathingSize; j++) { createCellAtRowCol(r+i, c+j, Water::new); From 0f06511dd85b2497ec42af6d9160367877fd2d1d Mon Sep 17 00:00:00 2001 From: James King Date: Mon, 16 Sep 2024 20:37:50 +1000 Subject: [PATCH 10/19] Better maze gen settings --- .../com/csse3200/game/components/minigames/maze/MazeGame.java | 2 +- .../game/components/minigames/maze/mazegrid/MazeGrid.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/source/core/src/main/com/csse3200/game/components/minigames/maze/MazeGame.java b/source/core/src/main/com/csse3200/game/components/minigames/maze/MazeGame.java index 52f03ad8a..c702f3d17 100644 --- a/source/core/src/main/com/csse3200/game/components/minigames/maze/MazeGame.java +++ b/source/core/src/main/com/csse3200/game/components/minigames/maze/MazeGame.java @@ -12,7 +12,7 @@ public class MazeGame { private final MinigameRenderer renderer; public MazeGame() { - this.grid = new MazeGrid(9, 3); + this.grid = new MazeGrid(12, 5); this.renderer = new MinigameRenderer(); initRenderers(); } diff --git a/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/MazeGrid.java b/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/MazeGrid.java index 6a1c5a34e..a3e595489 100644 --- a/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/MazeGrid.java +++ b/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/MazeGrid.java @@ -46,7 +46,7 @@ public MazeGrid(int size, int pathingSize) { this.size = size * (pathingSize + 1) + 1; this.cells = new MazeCell[this.size][this.size]; calculateCellDimensions(); - generateRandomMaze(pathingSize, 5); + generateRandomMaze(pathingSize, 10); } private void calculateCellDimensions() { From 050006b51f829962a3ace835e20b0b40b994fdb0 Mon Sep 17 00:00:00 2001 From: James King Date: Tue, 17 Sep 2024 08:05:33 +1000 Subject: [PATCH 11/19] Add box2dlights library and add sight radius --- source/build.gradle | 2 ++ .../csse3200/game/screens/MazeGameScreen.java | 17 ++++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/source/build.gradle b/source/build.gradle index 2d9bbc99b..c392ed245 100644 --- a/source/build.gradle +++ b/source/build.gradle @@ -94,6 +94,8 @@ project(":core") { api "org.slf4j:slf4j-api:$slf4jVersion" api "org.slf4j:slf4j-jdk14:$slf4jVersion" + api "com.badlogicgames.box2dlights:box2dlights:$box2DLightsVersion" + // Unit Testing testImplementation "org.junit.jupiter:junit-jupiter-api:$junit5Version" testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:$junit5Version' diff --git a/source/core/src/main/com/csse3200/game/screens/MazeGameScreen.java b/source/core/src/main/com/csse3200/game/screens/MazeGameScreen.java index edc9ded65..bc3b8663d 100644 --- a/source/core/src/main/com/csse3200/game/screens/MazeGameScreen.java +++ b/source/core/src/main/com/csse3200/game/screens/MazeGameScreen.java @@ -1,6 +1,8 @@ package com.csse3200.game.screens; import com.badlogic.gdx.graphics.g2d.BitmapFont; +import com.badlogic.gdx.math.Vector2; +import com.badlogic.gdx.physics.box2d.World; import com.badlogic.gdx.scenes.scene2d.InputEvent; import com.badlogic.gdx.scenes.scene2d.Stage; import com.badlogic.gdx.scenes.scene2d.ui.Skin; @@ -9,7 +11,6 @@ import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; import com.badlogic.gdx.Screen; import com.csse3200.game.components.minigames.KeyboardMiniGameInputComponent; -import com.csse3200.game.components.minigames.birdieDash.BirdieDashGame; import com.csse3200.game.components.minigames.birdieDash.controller.KeyboardBirdInputComponent; import com.csse3200.game.components.minigames.maze.MazeGame; import com.csse3200.game.input.InputComponent; @@ -31,6 +32,8 @@ import com.csse3200.game.services.GameTime; import com.csse3200.game.services.ServiceLocator; import com.csse3200.game.components.gamearea.PerformanceDisplay; +import box2dLight.RayHandler; +import box2dLight.PointLight; import static com.csse3200.game.components.minigames.MiniGameNames.BIRD; @@ -51,6 +54,8 @@ public class MazeGameScreen extends PausableScreen { private final ServiceContainer oldScreenServices; private final MazeGame mazeGame; + private final RayHandler rayHandler; + public MazeGameScreen(GdxGame game, Screen screen, ServiceContainer container) { super(game); this.scale = 1; @@ -79,6 +84,15 @@ public MazeGameScreen(GdxGame game, Screen screen, ServiceContainer container) { setupExitButton(); createUI(); + + World world = new World(new Vector2(0,0),false); + rayHandler = new RayHandler(world); + rayHandler.setCombinedMatrix(stage.getCamera().combined); //<-- pass your camera combined matrix + Color lightColor = new Color(0.55f, 0.45f, 0.75f, 1); + new PointLight(rayHandler,1000, lightColor,180,700,600); + RayHandler.useDiffuseLight(true); + + //LightSystem.rayHandler.setAmbientLight(lightColor) } /** @@ -95,6 +109,7 @@ public void render(float delta) { clearBackground(); mazeGame.render(); + rayHandler.updateAndRender(); // scoreBoard.updateScore(birdGame.getScore()); From 9ea2c2ab745b6813c6a0cd8e5e529285881ea2ba Mon Sep 17 00:00:00 2001 From: James King Date: Tue, 17 Sep 2024 09:40:58 +1000 Subject: [PATCH 12/19] Scale lighting with minigame renderer --- .../components/minigames/maze/MazeGame.java | 9 ++++++++- .../csse3200/game/screens/MazeGameScreen.java | 19 +++++++++++++++---- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/source/core/src/main/com/csse3200/game/components/minigames/maze/MazeGame.java b/source/core/src/main/com/csse3200/game/components/minigames/maze/MazeGame.java index c702f3d17..ef9c79852 100644 --- a/source/core/src/main/com/csse3200/game/components/minigames/maze/MazeGame.java +++ b/source/core/src/main/com/csse3200/game/components/minigames/maze/MazeGame.java @@ -18,12 +18,19 @@ public MazeGame() { } private void initRenderers() { - ServiceLocator.registerResourceService(new ResourceService()); renderer.addRenderable(new MazeGridRenderer(grid, renderer)); } public void render() { renderer.render(); } + + public void dispose() { + renderer.dispose(); + } + + public MinigameRenderer getRenderer() { + return renderer; + } } diff --git a/source/core/src/main/com/csse3200/game/screens/MazeGameScreen.java b/source/core/src/main/com/csse3200/game/screens/MazeGameScreen.java index bc3b8663d..13f607698 100644 --- a/source/core/src/main/com/csse3200/game/screens/MazeGameScreen.java +++ b/source/core/src/main/com/csse3200/game/screens/MazeGameScreen.java @@ -10,12 +10,14 @@ import com.badlogic.gdx.scenes.scene2d.ui.TextButton; import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; import com.badlogic.gdx.Screen; +import com.badlogic.gdx.utils.viewport.Viewport; import com.csse3200.game.components.minigames.KeyboardMiniGameInputComponent; import com.csse3200.game.components.minigames.birdieDash.controller.KeyboardBirdInputComponent; import com.csse3200.game.components.minigames.maze.MazeGame; import com.csse3200.game.input.InputComponent; import com.csse3200.game.input.InputDecorator; import com.csse3200.game.rendering.Renderer; +import com.csse3200.game.services.ResourceService; import com.csse3200.game.services.ServiceContainer; import com.csse3200.game.ui.minigames.ScoreBoard; import org.slf4j.Logger; @@ -68,6 +70,7 @@ public MazeGameScreen(GdxGame game, Screen screen, ServiceContainer container) { ServiceLocator.registerEntityService(new EntityService()); ServiceLocator.registerRenderService(new RenderService()); ServiceLocator.registerTimeSource(new GameTime()); + ServiceLocator.registerResourceService(new ResourceService()); renderer = RenderFactory.createRenderer(); @@ -87,9 +90,8 @@ public MazeGameScreen(GdxGame game, Screen screen, ServiceContainer container) { World world = new World(new Vector2(0,0),false); rayHandler = new RayHandler(world); - rayHandler.setCombinedMatrix(stage.getCamera().combined); //<-- pass your camera combined matrix Color lightColor = new Color(0.55f, 0.45f, 0.75f, 1); - new PointLight(rayHandler,1000, lightColor,180,700,600); + new PointLight(rayHandler,120, lightColor,180,1920/2,1200/2); RayHandler.useDiffuseLight(true); //LightSystem.rayHandler.setAmbientLight(lightColor) @@ -109,6 +111,7 @@ public void render(float delta) { clearBackground(); mazeGame.render(); + rayHandler.setCombinedMatrix(mazeGame.getRenderer().getCam().combined); rayHandler.updateAndRender(); // scoreBoard.updateScore(birdGame.getScore()); @@ -134,7 +137,8 @@ public void clearBackground() { */ @Override public void resize(int width, int height) { - stage.getViewport().update(width, height, true); + Viewport viewport = stage.getViewport(); + viewport.update(width, height, true); float baseWidth = 1920; float baseHeight = 1200; float scaleWidth = width / baseWidth; @@ -142,6 +146,11 @@ public void resize(int width, int height) { scale = Math.min(scaleWidth, scaleHeight); setupExitButton(); scoreBoard.resize(); + /*if(viewport.getRightGutterWidth() > 0){ + rayHandler.useCustomViewport(viewport.getRightGutterWidth()-5,viewport.getBottomGutterHeight()-5, (int)(height*1920f/1200)+10,height+10); + }else{ + rayHandler.useCustomViewport(viewport.getRightGutterWidth()-5,viewport.getBottomGutterHeight()-5, width+10,(int)(width/1920f*1200)+10); + }*/ } /** @@ -154,12 +163,14 @@ public void dispose() { logger.debug("Disposing birdie dash screen"); renderer.dispose(); + mazeGame.dispose(); ServiceLocator.getEntityService().dispose(); ServiceLocator.getRenderService().dispose(); + ServiceLocator.getResourceService().dispose(); ServiceLocator.clear(); font.dispose(); skin.dispose(); - stage.dispose(); + rayHandler.dispose(); } /** From 305498493ff267747e7930300c781da82a54720b Mon Sep 17 00:00:00 2001 From: James King Date: Tue, 17 Sep 2024 11:36:04 +1000 Subject: [PATCH 13/19] Lighting wall collisions --- .../components/minigames/maze/MazeGame.java | 59 ++++++++++++++++++- .../minigames/maze/mazegrid/MazeGrid.java | 4 ++ .../csse3200/game/screens/MazeGameScreen.java | 16 +---- 3 files changed, 63 insertions(+), 16 deletions(-) diff --git a/source/core/src/main/com/csse3200/game/components/minigames/maze/MazeGame.java b/source/core/src/main/com/csse3200/game/components/minigames/maze/MazeGame.java index ef9c79852..8a8329f71 100644 --- a/source/core/src/main/com/csse3200/game/components/minigames/maze/MazeGame.java +++ b/source/core/src/main/com/csse3200/game/components/minigames/maze/MazeGame.java @@ -1,20 +1,50 @@ package com.csse3200.game.components.minigames.maze; +import com.badlogic.gdx.graphics.Color; +import com.badlogic.gdx.math.Vector2; +import com.badlogic.gdx.physics.box2d.*; import com.csse3200.game.components.minigames.MinigameRenderer; +import com.csse3200.game.components.minigames.maze.mazegrid.MazeCell; import com.csse3200.game.components.minigames.maze.mazegrid.MazeGrid; +import com.csse3200.game.components.minigames.maze.mazegrid.Wall; import com.csse3200.game.components.minigames.maze.rendering.MazeGridRenderer; import com.csse3200.game.services.ResourceService; import com.csse3200.game.services.ServiceLocator; +import box2dLight.RayHandler; +import box2dLight.PointLight; public class MazeGame { private final MazeGrid grid; private final MinigameRenderer renderer; + private final RayHandler rayHandler; + + private Box2DDebugRenderer b2dr; + private World world; + private Body player; + public MazeGame() { - this.grid = new MazeGrid(12, 5); + this.grid = new MazeGrid(12, 6); this.renderer = new MinigameRenderer(); initRenderers(); + world = new World(new Vector2(0,0),false); + rayHandler = new RayHandler(world); + Color lightColor = new Color(0.55f, 0.45f, 0.75f, 1); + PointLight pl = new PointLight(rayHandler,180, lightColor,350,1920/2,1200/2); + RayHandler.useDiffuseLight(true); + pl.setPosition(800, 500); + //rayHandler.setAmbientLight(lightColor); + b2dr = new Box2DDebugRenderer(); + //player = createPlayer(); + for (int row = 0; row < grid.getSize(); row++) { + for (int col = 0; col < grid.getSize(); col++) { + MazeCell cell = grid.getCell(row, col); + if (cell instanceof Wall) { + createPlayer(cell.getPosition().x, cell.getPosition().y, cell.getSize(), cell.getSize()); + } + } + } } private void initRenderers() { @@ -23,14 +53,41 @@ private void initRenderers() { public void render() { renderer.render(); + //update(Gdx.graphics.getDeltaTime()); + + //b2dr.render(world, renderer.getCam().combined); + //rayHandler.setCombinedMatrix(renderer.getCam().combined); + //rayHandler.updateAndRender(); } public void dispose() { renderer.dispose(); + rayHandler.dispose(); + b2dr.dispose(); + world.dispose(); } public MinigameRenderer getRenderer() { return renderer; } + + private Body createPlayer(float x, float y, float width, float height) { + Body pBody; + BodyDef def = new BodyDef(); + def.type = BodyDef.BodyType.StaticBody; + def.position.set(x,y); + def.fixedRotation = true; + pBody = world.createBody(def); + + PolygonShape shape = new PolygonShape(); + shape.setAsBox(width / 2, height / 2); + + pBody.createFixture(shape, 1.0f); + shape.dispose(); + + + + return pBody; + } } diff --git a/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/MazeGrid.java b/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/MazeGrid.java index a3e595489..03661f69e 100644 --- a/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/MazeGrid.java +++ b/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/MazeGrid.java @@ -266,4 +266,8 @@ private void setUpInTest(String file) { System.out.println("Can't read line"); } } + + public int getSize() { + return size; + } } diff --git a/source/core/src/main/com/csse3200/game/screens/MazeGameScreen.java b/source/core/src/main/com/csse3200/game/screens/MazeGameScreen.java index 13f607698..e42c5a3c9 100644 --- a/source/core/src/main/com/csse3200/game/screens/MazeGameScreen.java +++ b/source/core/src/main/com/csse3200/game/screens/MazeGameScreen.java @@ -2,6 +2,7 @@ import com.badlogic.gdx.graphics.g2d.BitmapFont; import com.badlogic.gdx.math.Vector2; +import com.badlogic.gdx.physics.box2d.Box2DDebugRenderer; import com.badlogic.gdx.physics.box2d.World; import com.badlogic.gdx.scenes.scene2d.InputEvent; import com.badlogic.gdx.scenes.scene2d.Stage; @@ -34,8 +35,6 @@ import com.csse3200.game.services.GameTime; import com.csse3200.game.services.ServiceLocator; import com.csse3200.game.components.gamearea.PerformanceDisplay; -import box2dLight.RayHandler; -import box2dLight.PointLight; import static com.csse3200.game.components.minigames.MiniGameNames.BIRD; @@ -56,8 +55,6 @@ public class MazeGameScreen extends PausableScreen { private final ServiceContainer oldScreenServices; private final MazeGame mazeGame; - private final RayHandler rayHandler; - public MazeGameScreen(GdxGame game, Screen screen, ServiceContainer container) { super(game); this.scale = 1; @@ -87,14 +84,6 @@ public MazeGameScreen(GdxGame game, Screen screen, ServiceContainer container) { setupExitButton(); createUI(); - - World world = new World(new Vector2(0,0),false); - rayHandler = new RayHandler(world); - Color lightColor = new Color(0.55f, 0.45f, 0.75f, 1); - new PointLight(rayHandler,120, lightColor,180,1920/2,1200/2); - RayHandler.useDiffuseLight(true); - - //LightSystem.rayHandler.setAmbientLight(lightColor) } /** @@ -111,8 +100,6 @@ public void render(float delta) { clearBackground(); mazeGame.render(); - rayHandler.setCombinedMatrix(mazeGame.getRenderer().getCam().combined); - rayHandler.updateAndRender(); // scoreBoard.updateScore(birdGame.getScore()); @@ -170,7 +157,6 @@ public void dispose() { ServiceLocator.clear(); font.dispose(); skin.dispose(); - rayHandler.dispose(); } /** From 8834826a29a62f8b20c33f6837dd20e43099e76e Mon Sep 17 00:00:00 2001 From: James King Date: Tue, 17 Sep 2024 13:22:13 +1000 Subject: [PATCH 14/19] Moving light source --- .../components/minigames/maze/MazeGame.java | 31 +++++++++++++++++-- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/source/core/src/main/com/csse3200/game/components/minigames/maze/MazeGame.java b/source/core/src/main/com/csse3200/game/components/minigames/maze/MazeGame.java index 8a8329f71..2f2491dbe 100644 --- a/source/core/src/main/com/csse3200/game/components/minigames/maze/MazeGame.java +++ b/source/core/src/main/com/csse3200/game/components/minigames/maze/MazeGame.java @@ -1,5 +1,7 @@ package com.csse3200.game.components.minigames.maze; +import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.Input; import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.physics.box2d.*; @@ -23,6 +25,8 @@ public class MazeGame { private Box2DDebugRenderer b2dr; private World world; private Body player; + private PointLight pl; + private PointLight pl2; public MazeGame() { this.grid = new MazeGrid(12, 6); @@ -31,9 +35,12 @@ public MazeGame() { world = new World(new Vector2(0,0),false); rayHandler = new RayHandler(world); Color lightColor = new Color(0.55f, 0.45f, 0.75f, 1); - PointLight pl = new PointLight(rayHandler,180, lightColor,350,1920/2,1200/2); + pl = new PointLight(rayHandler,180, lightColor,350,1920/2,1200/2); + pl2 = new PointLight(rayHandler,180, lightColor,180,1920/2,1200/2); RayHandler.useDiffuseLight(true); pl.setPosition(800, 500); + pl2.setPosition(800, 500); + pl2.setXray(true); //rayHandler.setAmbientLight(lightColor); b2dr = new Box2DDebugRenderer(); //player = createPlayer(); @@ -53,11 +60,29 @@ private void initRenderers() { public void render() { renderer.render(); + float x = pl.getPosition().x, y = pl.getPosition().y; + + if(Gdx.input.isKeyPressed(Input.Keys.UP)) { + y += 4; + } + if(Gdx.input.isKeyPressed(Input.Keys.DOWN)) { + y -= 4; + } + if(Gdx.input.isKeyPressed(Input.Keys.LEFT)) { + x -= 4; + } + if(Gdx.input.isKeyPressed(Input.Keys.RIGHT)) { + x += 4; + } + + pl.setPosition(x, y); + pl2.setPosition(x, y); + //update(Gdx.graphics.getDeltaTime()); //b2dr.render(world, renderer.getCam().combined); - //rayHandler.setCombinedMatrix(renderer.getCam().combined); - //rayHandler.updateAndRender(); + rayHandler.setCombinedMatrix(renderer.getCam().combined); + rayHandler.updateAndRender(); } public void dispose() { From 7d90a630b71650b579d2fd31bef443933ed6a9fb Mon Sep 17 00:00:00 2001 From: Ella Berglas Date: Tue, 17 Sep 2024 21:34:19 +1000 Subject: [PATCH 15/19] Implemented maze to fish npc --- source/core/assets/configs/NPCs.json | 11 +++++++++-- .../com/csse3200/game/ui/dialoguebox/DialogueBox.java | 3 +-- .../game/entities/factories/NPCFactoryTest.java | 6 +++++- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/source/core/assets/configs/NPCs.json b/source/core/assets/configs/NPCs.json index 025f23e57..abe41aa17 100644 --- a/source/core/assets/configs/NPCs.json +++ b/source/core/assets/configs/NPCs.json @@ -47,7 +47,10 @@ }, "snake": { "baseHint": [ - ["HHIISSSSSSS, I am the mighty Snake of the Jungle!","You look very tasty and I am very hungry","Go play a game and collect me some apples...","/msOr I will eat you whole!"] + ["HHIISSSSSSS, I am the mighty Snake of the Jungle!", + "You look very tasty and I am very hungry", + "Go play a game and collect me some apples...", + "/msOr I will eat you whole!"] ], "spritePath": "images/snake.atlas", "animationSpeed": 0.2, @@ -68,7 +71,11 @@ "fish": { "baseHint": [ - ["Welcome to Animal Kingdom!","I am Finny the Fish."] + ["Help me please!", + "A strong current just scattered all my eggs and now I am lost", + "It is getting dark now, they are in great danger!", + "I must get them back and find my way home!", + "/muHelp me collect all the fish eggs an get back home before it is too late"] ], "spritePath": "images/Fish.atlas", "animationSpeed": 0.2, diff --git a/source/core/src/main/com/csse3200/game/ui/dialoguebox/DialogueBox.java b/source/core/src/main/com/csse3200/game/ui/dialoguebox/DialogueBox.java index 23e1c4fcf..0455614e8 100644 --- a/source/core/src/main/com/csse3200/game/ui/dialoguebox/DialogueBox.java +++ b/source/core/src/main/com/csse3200/game/ui/dialoguebox/DialogueBox.java @@ -200,7 +200,6 @@ private void createForwardButton() { /** * Creates the backward button for navigating to the previous hint. * - * @return The TextButton instance. */ private void createBackwardButton() { float desiredHeight = screenHeight * 0.05f; // button image height @@ -299,7 +298,7 @@ public boolean touchDown(InputEvent event, float x, float y, int pointer, int bu } else if (currentMinigame == BIRD) { gdxGame.enterBirdieDashScreen(); } else if (currentMinigame == MAZE) { - // TODO: Implement underwater maze (sprint 4) + gdxGame.enterMazeGameScreen(); } return true; } diff --git a/source/core/src/test/com/csse3200/game/entities/factories/NPCFactoryTest.java b/source/core/src/test/com/csse3200/game/entities/factories/NPCFactoryTest.java index 05cfe8643..4bb0cdde1 100644 --- a/source/core/src/test/com/csse3200/game/entities/factories/NPCFactoryTest.java +++ b/source/core/src/test/com/csse3200/game/entities/factories/NPCFactoryTest.java @@ -184,7 +184,11 @@ void TestFishHasCorrectSoundPath() { void TestFishHasCorrectBaseHint() { String[][] baseHint = configs.fish.getBaseHint(); assertNotNull(baseHint); - Assertions.assertArrayEquals(new String[][]{{"Welcome to Animal Kingdom!", "I am Finny the Fish."}}, baseHint); + Assertions.assertArrayEquals(new String[][]{{"Help me please!", + "A strong current just scattered all my eggs and now I am lost", + "It is getting dark now, they are in great danger!", + "I must get them back and find my way home!", + "/muHelp me collect all the fish eggs an get back home before it is too late"}}, baseHint); } /** From 8c336d21ec93ea481c5fc9e5fa6a978bac5fa94d Mon Sep 17 00:00:00 2001 From: Ella Berglas Date: Tue, 17 Sep 2024 22:32:55 +1000 Subject: [PATCH 16/19] Added extra return to game button when the mini-game is played from the main game. Fixed code modulaity --- .../game/screens/EndMiniGameScreen.java | 100 +++++++++++------- 1 file changed, 62 insertions(+), 38 deletions(-) diff --git a/source/core/src/main/com/csse3200/game/screens/EndMiniGameScreen.java b/source/core/src/main/com/csse3200/game/screens/EndMiniGameScreen.java index 4b6bc6cc7..6e19ecb1e 100644 --- a/source/core/src/main/com/csse3200/game/screens/EndMiniGameScreen.java +++ b/source/core/src/main/com/csse3200/game/screens/EndMiniGameScreen.java @@ -57,6 +57,7 @@ public class EndMiniGameScreen extends ScreenAdapter { private final Entity player; private PlayerInventoryDisplay display; + private Table contentTable; public EndMiniGameScreen(GdxGame game, int score, MiniGameNames gameName, Screen screen, ServiceContainer container) { this.game = game; @@ -107,14 +108,7 @@ private void setupExitButton() { public void clicked(InputEvent event, float x, float y) { // Return to main menu and original screen colour Gdx.gl.glClearColor(248f / 255f, 249f / 255f, 178f / 255f, 1f); - switch(getMedal(score)) { - case BRONZE -> display.getEntity().getEvents().trigger("addItem", new EarlyGameLootBox( - new EarlyGameLootTable(),3 , player)); - case SILVER -> display.getEntity().getEvents().trigger("addItem", new MediumGameLootBox( - new MediumGameLootTable(),3 , player)); - case GOLD -> display.getEntity().getEvents().trigger("addItem", new LateGameLootBox( - new LateGameLootTable(),3 , player)); - } + getLootBox(); game.setOldScreen(oldScreen, oldScreenServices); } }); @@ -130,6 +124,21 @@ public void clicked(InputEvent event, float x, float y) { stage.addActor(table); } + /** + * Gives the player a loot box + */ + private void getLootBox() { + //TODO: change this only so when the medal changes + switch(getMedal(score)) { + case BRONZE -> display.getEntity().getEvents().trigger("addItem", new EarlyGameLootBox( + new EarlyGameLootTable(),3 , player)); + case SILVER -> display.getEntity().getEvents().trigger("addItem", new MediumGameLootBox( + new MediumGameLootTable(),3 , player)); + case GOLD -> display.getEntity().getEvents().trigger("addItem", new LateGameLootBox( + new LateGameLootTable(),3 , player)); + } + } + /** * Renders the screen. Sets the background colour, draws the UI elements (buttons) and * renders the message labels and handles key presses @@ -146,12 +155,13 @@ public void render(float delta) { // Render the game over messages renderEndMessage(); + stage.addActor(contentTable); handleKeyPress(); } /** - * Changes the screen if escape or R is pressed (to mini-games menu or back to game respectively) + * Changes the screen if backspace or R is pressed (to mini-games menu or back to game respectively) */ private void handleKeyPress() { @@ -164,7 +174,7 @@ private void handleKeyPress() { else if (gameName == BIRD) { game.setScreen(new BirdieDashScreen(game, oldScreen, oldScreenServices)); } else { - //TODO: add Maze screen + game.setScreen(new MazeGameScreen(game, oldScreen, oldScreenServices)); } } @@ -176,26 +186,25 @@ else if (gameName == BIRD) { /** * Renders the labels with score, message and title. - * Renders the try again and menu buttons */ private void renderEndMessage() { - Table table = new Table(); - table.setFillParent(true); + contentTable = new Table(); + contentTable.setFillParent(true); // End of Mini-Game label font32.getData().setScale(3f * scale); Label.LabelStyle labelStyle = new Label.LabelStyle(font32, Color.WHITE); Label endGameLabel = new Label("End of Mini-Game", labelStyle); - table.add(endGameLabel).center().padBottom(80 * scale).row(); - table.row(); + contentTable.add(endGameLabel).center().padBottom(80 * scale).row(); + contentTable.row(); // Score label font26.getData().setScale(2f * scale); labelStyle = new Label.LabelStyle(font26, Color.WHITE); Label scoreLabel = new Label("Score: " + score, labelStyle); - table.add(scoreLabel).center().padBottom(50 * scale).row(); - table.row(); + contentTable.add(scoreLabel).center().padBottom(50 * scale).row(); + contentTable.row(); // Medal label MiniGameMedals medal = getMedal(score); @@ -203,15 +212,15 @@ private void renderEndMessage() { font26.getData().setScale(2f * scale); labelStyle = new Label.LabelStyle(font26, Color.WHITE); Label medalLabel = new Label("You FAILED", labelStyle); - table.add(medalLabel).center().padBottom(150 * scale).row(); - table.row(); + contentTable.add(medalLabel).center().padBottom(150 * scale).row(); + contentTable.row(); } else { font26.getData().setScale(2f * scale); labelStyle = new Label.LabelStyle(font26, Color.WHITE); Label medalLabel = new Label("You got a " + medal + " Medal :)", labelStyle); - table.add(medalLabel).center().padBottom(150 * scale).row(); - table.row(); + contentTable.add(medalLabel).center().padBottom(150 * scale).row(); + contentTable.row(); } // Personalised message label @@ -219,48 +228,63 @@ private void renderEndMessage() { labelStyle = new Label.LabelStyle(font18, Color.WHITE); String scoreMessage = getMessage(); Label scoreMessageLabel = new Label(scoreMessage, labelStyle); - table.add(scoreMessageLabel).center().padBottom(100 * scale); - table.row(); + contentTable.add(scoreMessageLabel).center().padBottom(100 * scale); + contentTable.row(); - // Add buttons to the table + makeButtons(); + } + + /** + * Renders the try again, menu and back to game buttons + */ + private void makeButtons() { + // Make try again button TextButton tryAgainButton = new TextButton("Try Again", skin); - // Scale the button's font tryAgainButton.getLabel().setFontScale(scale); - - // Scale the button's size tryAgainButton.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { dispose(); if (gameName == SNAKE) { game.setScreen(new SnakeScreen(game, oldScreen, oldScreenServices)); - } - else if (gameName == BIRD) { + } else if (gameName == BIRD) { game.setScreen(new BirdieDashScreen(game, oldScreen, oldScreenServices)); } else { - //TODO: add Maze screen + game.setScreen(new MazeGameScreen(game, oldScreen, oldScreenServices)); } } }); - TextButton menuButton = new TextButton("Mini-Game Menu", skin); - // Scale the button's font + // Make Mini-Game Menu Button + TextButton menuButton = new TextButton("Main Menu", skin); menuButton.getLabel().setFontScale(scale); - - // Scale the button's size menuButton.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { Gdx.gl.glClearColor(248f / 255f, 249f / 255f, 178f / 255f, 1f); - game.setOldScreen(oldScreen, oldScreenServices); + game.setScreen(GdxGame.ScreenType.MAIN_MENU); } }); // Add buttons to the table and align them at the bottom - table.add(tryAgainButton).width(tryAgainButton.getWidth() * scale).height(tryAgainButton.getHeight() * scale).pad(10 * scale).row(); - table.add(menuButton).width(menuButton.getWidth() * scale).height(menuButton.getHeight() * scale).center().pad(10 * scale).row(); + contentTable.add(tryAgainButton).width(tryAgainButton.getWidth() * scale).height(tryAgainButton.getHeight() * scale).pad(10 * scale).row(); + contentTable.add(menuButton).width(menuButton.getWidth() * scale).height(menuButton.getHeight() * scale).center().pad(10 * scale).row(); - stage.addActor(table); + // Makes return to game button appear only if it came from the game screen + if (oldScreen instanceof MainGameScreen) { + // Make Mini-Game Menu Button + TextButton mainGameButton = new TextButton("Return to Game", skin); + mainGameButton.getLabel().setFontScale(scale); + mainGameButton.addListener(new ClickListener() { + @Override + public void clicked(InputEvent event, float x, float y) { + Gdx.gl.glClearColor(248f / 255f, 249f / 255f, 178f / 255f, 1f); + getLootBox(); + game.setOldScreen(oldScreen, oldScreenServices); + } + }); + contentTable.add(mainGameButton).width(mainGameButton.getWidth() * scale).height(mainGameButton.getHeight() * scale).center().pad(10 * scale).row(); + } } /** From 7e942dd7af4e1edc86d2f7515801166e7ba90d96 Mon Sep 17 00:00:00 2001 From: Ella Berglas Date: Tue, 17 Sep 2024 23:12:42 +1000 Subject: [PATCH 17/19] Styling and added WASD key inputs --- .../minigames/maze/MazeAssetPaths.java | 3 ++ .../components/minigames/maze/MazeGame.java | 32 +++++++++-- .../minigames/maze/mazegrid/MazeCell.java | 18 ++++++- .../minigames/maze/mazegrid/MazeGrid.java | 46 ++++++++++------ .../minigames/maze/mazegrid/Spawn.java | 3 ++ .../minigames/maze/mazegrid/Wall.java | 3 ++ .../minigames/maze/mazegrid/Water.java | 3 ++ .../maze/rendering/MazeGridRenderer.java | 7 ++- .../game/screens/EndMiniGameScreen.java | 53 +++++++++---------- .../csse3200/game/screens/MazeGameScreen.java | 38 +++++-------- 10 files changed, 131 insertions(+), 75 deletions(-) diff --git a/source/core/src/main/com/csse3200/game/components/minigames/maze/MazeAssetPaths.java b/source/core/src/main/com/csse3200/game/components/minigames/maze/MazeAssetPaths.java index 57ba30a1a..f98a98d37 100644 --- a/source/core/src/main/com/csse3200/game/components/minigames/maze/MazeAssetPaths.java +++ b/source/core/src/main/com/csse3200/game/components/minigames/maze/MazeAssetPaths.java @@ -1,5 +1,8 @@ package com.csse3200.game.components.minigames.maze; +/** + * Class for assets for underwater maze mini-game + */ public class MazeAssetPaths { // Mazes diff --git a/source/core/src/main/com/csse3200/game/components/minigames/maze/MazeGame.java b/source/core/src/main/com/csse3200/game/components/minigames/maze/MazeGame.java index 2f2491dbe..ca05126b1 100644 --- a/source/core/src/main/com/csse3200/game/components/minigames/maze/MazeGame.java +++ b/source/core/src/main/com/csse3200/game/components/minigames/maze/MazeGame.java @@ -15,6 +15,9 @@ import box2dLight.RayHandler; import box2dLight.PointLight; +/** + * CLass for the underwater maze game functionality + */ public class MazeGame { private final MazeGrid grid; @@ -54,24 +57,30 @@ public MazeGame() { } } + /** + * Renders the maze + */ private void initRenderers() { renderer.addRenderable(new MazeGridRenderer(grid, renderer)); } + /** + * Updates the maze rendering + */ public void render() { renderer.render(); float x = pl.getPosition().x, y = pl.getPosition().y; - if(Gdx.input.isKeyPressed(Input.Keys.UP)) { + if(Gdx.input.isKeyPressed(Input.Keys.UP) || Gdx.input.isKeyPressed(Input.Keys.W)) { y += 4; } - if(Gdx.input.isKeyPressed(Input.Keys.DOWN)) { + if(Gdx.input.isKeyPressed(Input.Keys.DOWN) || Gdx.input.isKeyPressed(Input.Keys.S)) { y -= 4; } - if(Gdx.input.isKeyPressed(Input.Keys.LEFT)) { + if(Gdx.input.isKeyPressed(Input.Keys.LEFT) || Gdx.input.isKeyPressed(Input.Keys.A)) { x -= 4; } - if(Gdx.input.isKeyPressed(Input.Keys.RIGHT)) { + if(Gdx.input.isKeyPressed(Input.Keys.RIGHT) || Gdx.input.isKeyPressed(Input.Keys.D)) { x += 4; } @@ -85,6 +94,9 @@ public void render() { rayHandler.updateAndRender(); } + /** + * Disposes + */ public void dispose() { renderer.dispose(); rayHandler.dispose(); @@ -92,10 +104,22 @@ public void dispose() { world.dispose(); } + /** + * Uses the mini-game renderer + * @return the mini-game renderer + */ public MinigameRenderer getRenderer() { return renderer; } + /** + * Creates a player in the maze + * @param x start x coordinate + * @param y start y coordinate + * @param width player width + * @param height player height + * @return the players body + */ private Body createPlayer(float x, float y, float width, float height) { Body pBody; BodyDef def = new BodyDef(); diff --git a/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/MazeCell.java b/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/MazeCell.java index 671982027..0a6831fbd 100644 --- a/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/MazeCell.java +++ b/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/MazeCell.java @@ -18,19 +18,35 @@ public MazeCell(float x, float y, float size) { this.collisionBox = new Rectangle(x, y, tileSize, tileSize); } + /** + * Gets the size of each tile in the maze + * @return the size of each tile in the maze + */ public float getSize() { return tileSize; } + /** + * set the position of the maze tile + * @param x the x coordinate + * @param y the y coordinate + */ public void setPosition(float x, float y) { position.set(x, y); } + /** + * Gets the tiles position + * @return + */ public Vector2 getPosition() { return this.position; } - + /** + * Determines if this tile has a collision + * @return tru if collision, otherwise false + */ public Rectangle getCollisionBox() { return this.collisionBox; } diff --git a/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/MazeGrid.java b/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/MazeGrid.java index 03661f69e..8761b747e 100644 --- a/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/MazeGrid.java +++ b/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/MazeGrid.java @@ -49,6 +49,9 @@ public MazeGrid(int size, int pathingSize) { generateRandomMaze(pathingSize, 10); } + /** + * Calculates the size a cell should be based on screen dimensions + */ private void calculateCellDimensions() { this.gridX = (screenWidth - gridWidth) / 2; // Center the grid horizontally this.gridY = (screenHeight - gridHeight) / 2; // Center the grid vertically @@ -59,12 +62,16 @@ private void calculateCellDimensions() { * Method to get the cell at a specific coordinate * @param row the row * @param col the column - * @return + * @return the cell of the maze at the coordinate */ public MazeCell getCell(int row, int col) { return cells[row][col]; } + /** + * Gets the maze + * @return the maze + */ public MazeCell[][] getMaze() { return cells; } @@ -92,7 +99,7 @@ private void generateRandomMaze(int pathingSize, int numSpawns) { spanningTree.add(new GridCell(c, r)); for (int i = 0; i < numSpawns; i++) { - BFS bfs = new BFS(spanningTree); + breadthFirstSearchMaze bfs = new breadthFirstSearchMaze(spanningTree); GridCell mostDistant = bfs.getMostDistant(); createCellAtRowCol(mostDistant.getY(), mostDistant.getX(), Spawn::new); List path = bfs.getShortestPath(bfs.getMostDistant()); @@ -102,6 +109,12 @@ private void generateRandomMaze(int pathingSize, int numSpawns) { } } + /** + * Determines a position is in bounds of the maze + * @param r row + * @param c column + * @return true if not in bounds, otherwise false + */ private boolean notInBounds(int r, int c) { return r < 0 || r >= size || c < 0 || c >= size; } @@ -133,32 +146,26 @@ private void recursiveBacktracking(int r, int c, int pathingSize, Random rand) { } for (int i = 0; i < pathingSize; i++) { switch (d) { - case UP: - createCellAtRowCol(r+pathingSize, c+i, Water::new); - break; - case DOWN: - createCellAtRowCol(r-1, c+i, Water::new); - break; - case RIGHT: - createCellAtRowCol(r+i, c+pathingSize, Water::new); - break; - case LEFT: - createCellAtRowCol(r+i, c-1, Water::new); - break; + case UP -> createCellAtRowCol(r + pathingSize, c + i, Water::new); + case DOWN -> createCellAtRowCol(r - 1, c + i, Water::new); + case RIGHT -> createCellAtRowCol(r + i, c + pathingSize, Water::new); + case LEFT -> createCellAtRowCol(r + i, c - 1, Water::new); } } recursiveBacktracking(nr, nc, pathingSize, rand); } } - class BFS { + /** + * Class for bfs + */ + class breadthFirstSearchMaze { int[][] distances; GridCell[][] previous; - GridCell mostDistant; static final Direction[] directions = {Direction.UP, Direction.DOWN, Direction.LEFT, Direction.RIGHT}; - BFS(List startCells) { + breadthFirstSearchMaze(List startCells) { distances = new int[size][size]; previous = new GridCell[size][size]; for (int r = 0; r < size; r++) { @@ -188,6 +195,11 @@ class BFS { mostDistant = cell; } + /** + * get shorted path from initial grid cell to current + * @param end the grid cell to search for + * @return the shortest path + */ List getShortestPath(GridCell end) { List path = new ArrayList<>(); while (end != null) { diff --git a/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/Spawn.java b/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/Spawn.java index 03dbd78ce..1f09f64c1 100644 --- a/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/Spawn.java +++ b/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/Spawn.java @@ -1,5 +1,8 @@ package com.csse3200.game.components.minigames.maze.mazegrid; +/** + * Class to spawn the maze of the underwater maze game + */ public class Spawn extends MazeCell{ public Spawn(float x, float y, float size) { super(x, y, size); diff --git a/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/Wall.java b/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/Wall.java index e73dcee4d..34ddf7e4f 100644 --- a/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/Wall.java +++ b/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/Wall.java @@ -1,5 +1,8 @@ package com.csse3200.game.components.minigames.maze.mazegrid; +/** + * Class to create walls for the maze + */ public class Wall extends MazeCell{ public Wall(float x, float y, float size) { super(x, y, size); diff --git a/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/Water.java b/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/Water.java index d7b93700e..bce6041a7 100644 --- a/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/Water.java +++ b/source/core/src/main/com/csse3200/game/components/minigames/maze/mazegrid/Water.java @@ -1,5 +1,8 @@ package com.csse3200.game.components.minigames.maze.mazegrid; +/** + * Class to creat water cell (not a wall) + */ public class Water extends MazeCell { public Water(float x, float y, float size) { super(x, y, size); diff --git a/source/core/src/main/com/csse3200/game/components/minigames/maze/rendering/MazeGridRenderer.java b/source/core/src/main/com/csse3200/game/components/minigames/maze/rendering/MazeGridRenderer.java index 3ed51045f..47744ff55 100644 --- a/source/core/src/main/com/csse3200/game/components/minigames/maze/rendering/MazeGridRenderer.java +++ b/source/core/src/main/com/csse3200/game/components/minigames/maze/rendering/MazeGridRenderer.java @@ -11,6 +11,9 @@ import com.csse3200.game.services.ResourceService; import com.csse3200.game.services.ServiceLocator; +/** + * Render for the underwater maze mini-game + */ public class MazeGridRenderer implements MinigameRenderable { private final MazeCell[][] maze; @@ -20,13 +23,15 @@ public class MazeGridRenderer implements MinigameRenderable { private Texture spawnTexture; - public MazeGridRenderer(MazeGrid grid, MinigameRenderer renderer) { this.maze = grid.getMaze(); this.renderer = renderer; loadAssets(); } + /** + * Renders the maze + */ public void render() { for (int row = 0; row < maze.length; row++) { for (int col = 0; col < maze[row].length; col++) { diff --git a/source/core/src/main/com/csse3200/game/screens/EndMiniGameScreen.java b/source/core/src/main/com/csse3200/game/screens/EndMiniGameScreen.java index 6e19ecb1e..76c53a0b4 100644 --- a/source/core/src/main/com/csse3200/game/screens/EndMiniGameScreen.java +++ b/source/core/src/main/com/csse3200/game/screens/EndMiniGameScreen.java @@ -74,13 +74,11 @@ public EndMiniGameScreen(GdxGame game, int score, MiniGameNames gameName, Screen this.font26 = new BitmapFont(Gdx.files.internal("flat-earth/skin/fonts/pixel_26.fnt")); this.font32 = new BitmapFont(Gdx.files.internal("flat-earth/skin/fonts/pixel_32.fnt")); + // Rewarding achievement to player if (oldScreen instanceof MainGameScreen) { - MainGameScreen forestGameArea = (MainGameScreen) oldScreen; this.player = MapHandler.getCurrentMap().getPlayer(); if (player != null) { - logger.info("Adding loot box to player's inventory."); this.display = player.getComponent(PlayerInventoryDisplay.class); - // Rewarding achievement to player logger.info("Achievement trigger {} {}", gameName.name(),getMedal(score).name()); player.getEvents().trigger("miniGame",gameName,getMedal(score)); } @@ -93,6 +91,27 @@ public EndMiniGameScreen(GdxGame game, int score, MiniGameNames gameName, Screen setupExitButton(); } + /** + * Renders the screen. Sets the background colour, draws the UI elements (buttons) and + * renders the message labels and handles key presses + * @param delta The time in seconds since the last render. + */ + @Override + public void render(float delta) { + // Set the background color based on the score + setBackgroundColor(); + + // Draw the exit button and other UI elements + stage.act(Gdx.graphics.getDeltaTime()); + stage.draw(); + + // Render the game over messages + renderEndMessage(); + stage.addActor(contentTable); + + handleKeyPress(); + } + /** * Puts the exit button in the top right of the screen. * Will take the user back to the Main menu screen @@ -108,7 +127,7 @@ private void setupExitButton() { public void clicked(InputEvent event, float x, float y) { // Return to main menu and original screen colour Gdx.gl.glClearColor(248f / 255f, 249f / 255f, 178f / 255f, 1f); - getLootBox(); + giveLootBox(); game.setOldScreen(oldScreen, oldScreenServices); } }); @@ -127,7 +146,8 @@ public void clicked(InputEvent event, float x, float y) { /** * Gives the player a loot box */ - private void getLootBox() { + private void giveLootBox() { + logger.info("Adding loot box to player's inventory."); //TODO: change this only so when the medal changes switch(getMedal(score)) { case BRONZE -> display.getEntity().getEvents().trigger("addItem", new EarlyGameLootBox( @@ -139,27 +159,6 @@ private void getLootBox() { } } - /** - * Renders the screen. Sets the background colour, draws the UI elements (buttons) and - * renders the message labels and handles key presses - * @param delta The time in seconds since the last render. - */ - @Override - public void render(float delta) { - // Set the background color based on the score - setBackgroundColor(); - - // Draw the exit button and other UI elements - stage.act(Gdx.graphics.getDeltaTime()); - stage.draw(); - - // Render the game over messages - renderEndMessage(); - stage.addActor(contentTable); - - handleKeyPress(); - } - /** * Changes the screen if backspace or R is pressed (to mini-games menu or back to game respectively) */ @@ -279,7 +278,7 @@ public void clicked(InputEvent event, float x, float y) { @Override public void clicked(InputEvent event, float x, float y) { Gdx.gl.glClearColor(248f / 255f, 249f / 255f, 178f / 255f, 1f); - getLootBox(); + giveLootBox(); game.setOldScreen(oldScreen, oldScreenServices); } }); diff --git a/source/core/src/main/com/csse3200/game/screens/MazeGameScreen.java b/source/core/src/main/com/csse3200/game/screens/MazeGameScreen.java index e42c5a3c9..d87946567 100644 --- a/source/core/src/main/com/csse3200/game/screens/MazeGameScreen.java +++ b/source/core/src/main/com/csse3200/game/screens/MazeGameScreen.java @@ -1,9 +1,6 @@ package com.csse3200.game.screens; import com.badlogic.gdx.graphics.g2d.BitmapFont; -import com.badlogic.gdx.math.Vector2; -import com.badlogic.gdx.physics.box2d.Box2DDebugRenderer; -import com.badlogic.gdx.physics.box2d.World; import com.badlogic.gdx.scenes.scene2d.InputEvent; import com.badlogic.gdx.scenes.scene2d.Stage; import com.badlogic.gdx.scenes.scene2d.ui.Skin; @@ -13,9 +10,7 @@ import com.badlogic.gdx.Screen; import com.badlogic.gdx.utils.viewport.Viewport; import com.csse3200.game.components.minigames.KeyboardMiniGameInputComponent; -import com.csse3200.game.components.minigames.birdieDash.controller.KeyboardBirdInputComponent; import com.csse3200.game.components.minigames.maze.MazeGame; -import com.csse3200.game.input.InputComponent; import com.csse3200.game.input.InputDecorator; import com.csse3200.game.rendering.Renderer; import com.csse3200.game.services.ResourceService; @@ -37,13 +32,14 @@ import com.csse3200.game.components.gamearea.PerformanceDisplay; import static com.csse3200.game.components.minigames.MiniGameNames.BIRD; +import static com.csse3200.game.components.minigames.MiniGameNames.MAZE; /** - * Class for Birdie Dash Game Screen + * Class for Underwater Maze Game Screen */ public class MazeGameScreen extends PausableScreen { - private static final Logger logger = LoggerFactory.getLogger(BirdieDashScreen.class); + private static final Logger logger = LoggerFactory.getLogger(MazeGameScreen.class); private final Renderer renderer; private final BitmapFont font; private final Skin skin; @@ -62,7 +58,7 @@ public MazeGameScreen(GdxGame game, Screen screen, ServiceContainer container) { this.oldScreen = screen; this.oldScreenServices = container; this.skin = new Skin(Gdx.files.internal("flat-earth/skin/flat-earth-ui.json")); - logger.debug("Initialising birdie dash screen services"); + logger.debug("Initialising maze game screen services"); ServiceLocator.registerInputService(new InputService()); ServiceLocator.registerEntityService(new EntityService()); ServiceLocator.registerRenderService(new RenderService()); @@ -78,9 +74,9 @@ public MazeGameScreen(GdxGame game, Screen screen, ServiceContainer container) { this.stage = ServiceLocator.getRenderService().getStage(); this.mazeGame = new MazeGame(); - this.scoreBoard = new ScoreBoard(0, BIRD); + this.scoreBoard = new ScoreBoard(0, MAZE); -// logger.debug("Initialising birdie dash entities"); +// logger.debug("Initialising maze game entities"); setupExitButton(); createUI(); @@ -92,23 +88,15 @@ public MazeGameScreen(GdxGame game, Screen screen, ServiceContainer container) { */ @Override public void render(float delta) { - if (!resting) { - for (int i = 0; i < 20; i++) { -// birdGame.update(delta / 20); - } - } - clearBackground(); mazeGame.render(); -// scoreBoard.updateScore(birdGame.getScore()); +// scoreBoard.updateScore(mazeGame.getScore()); stage.act(delta); // Update the stage stage.draw(); // Draw the UI (pause overlay) } - - /** * Clears the screen background */ @@ -147,7 +135,7 @@ public void resize(int width, int height) { public void dispose() { Gdx.gl.glClearColor(248f / 255f, 249f / 255f, 178f / 255f, 1f); - logger.debug("Disposing birdie dash screen"); + logger.debug("Disposing underwater maze screen"); renderer.dispose(); mazeGame.dispose(); @@ -185,19 +173,19 @@ public void clicked(InputEvent event, float x, float y) { * set up ui for key inputs */ private void createUI() { - logger.debug("Creating birdie dash ui"); + logger.debug("Creating maze ui"); Stage stage = ServiceLocator.getRenderService().getStage(); - InputComponent inputComponent = new KeyboardBirdInputComponent(); + //InputComponent inputComponent = new KeyboardBirdInputComponent(); Entity ui = new Entity(); ui .addComponent(new InputDecorator(stage, 10)) .addComponent(new PerformanceDisplay()) - .addComponent(inputComponent) + //.addComponent(inputComponent) .addComponent(new KeyboardMiniGameInputComponent()); - ui.getEvents().addListener("addOverlay", this::addOverlay); - ui.getEvents().addListener("removeOverlay", this::removeOverlay); +// ui.getEvents().addListener("addOverlay", this::addOverlay); +// ui.getEvents().addListener("removeOverlay", this::removeOverlay); ui.getEvents().addListener("restart", this::restartGame); ui.getEvents().addListener("exit", this::exitGame); From b79e51fa841013f4071410210d07a64ad2d12aac Mon Sep 17 00:00:00 2001 From: Ella Berglas Date: Tue, 17 Sep 2024 23:43:23 +1000 Subject: [PATCH 18/19] remove quests.json --- .../game/components/minigames/maze/MazeGame.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/source/core/src/main/com/csse3200/game/components/minigames/maze/MazeGame.java b/source/core/src/main/com/csse3200/game/components/minigames/maze/MazeGame.java index ca05126b1..aa021b14c 100644 --- a/source/core/src/main/com/csse3200/game/components/minigames/maze/MazeGame.java +++ b/source/core/src/main/com/csse3200/game/components/minigames/maze/MazeGame.java @@ -10,8 +10,6 @@ import com.csse3200.game.components.minigames.maze.mazegrid.MazeGrid; import com.csse3200.game.components.minigames.maze.mazegrid.Wall; import com.csse3200.game.components.minigames.maze.rendering.MazeGridRenderer; -import com.csse3200.game.services.ResourceService; -import com.csse3200.game.services.ServiceLocator; import box2dLight.RayHandler; import box2dLight.PointLight; @@ -25,11 +23,11 @@ public class MazeGame { private final RayHandler rayHandler; - private Box2DDebugRenderer b2dr; - private World world; + private final Box2DDebugRenderer b2dr; + private final World world; private Body player; - private PointLight pl; - private PointLight pl2; + private final PointLight pl; + private final PointLight pl2; public MazeGame() { this.grid = new MazeGrid(12, 6); From c4210dd385a6926307de0874970436c9ed21a2e0 Mon Sep 17 00:00:00 2001 From: Ella Berglas Date: Wed, 18 Sep 2024 16:58:14 +1000 Subject: [PATCH 19/19] Fully delete quests json --- saves/quests.json | 117 ---------------------------------------------- 1 file changed, 117 deletions(-) delete mode 100644 saves/quests.json diff --git a/saves/quests.json b/saves/quests.json deleted file mode 100644 index fd41f4448..000000000 --- a/saves/quests.json +++ /dev/null @@ -1,117 +0,0 @@ -{ -quests: [ - { - questName: First Steps - questDescription: Take your first steps in this world! - tasks: { - class: java.util.ImmutableCollections$List12 - items: [ - { - taskName: steps - description: Take your first steps - hint: Just start moving! - requiredTriggers: 1 - triggerCount: 1 - completed: true - failed: false - } - ] - } - isSecretQuest: false - questDialogue: null - currentTaskIndex: 1 - isFailed: false - isActive: false - taskCompletionTriggers: null - } - { - questName: 2 Task Quest - questDescription: Move then Attack for a Test Quest - tasks: { - class: java.util.ImmutableCollections$List12 - items: [ - { - taskName: steps - description: Take your first steps - hint: Just start moving! - requiredTriggers: 1 - triggerCount: 1 - completed: true - failed: false - } - { - taskName: attack - description: Swing your first sword - hint: Just Attack! - requiredTriggers: 1 - triggerCount: 0 - completed: false - failed: false - } - ] - } - isSecretQuest: false - questDialogue: { - class: java.util.ImmutableCollections$MapN - TupleKey{str='Cow', num=2}: [ - Yippeee! - You completed your Quest! - ] - TupleKey{str='Cow', num=1}: [ - Welcome to Animal Kingdom! - Here let me help with your quest... - Press Spacebar! - ] - } - currentTaskIndex: 0 - isFailed: false - isActive: false - taskCompletionTriggers: [ - "" - spawnKangaBoss - ] - } - { - questName: Final Boss - questDescription: Complete quest 1 and 2 to summon the boss - tasks: { - class: java.util.ImmutableCollections$ListN - items: [ - { - taskName: spawnKangaBoss - description: He is Coming... - hint: RUN - requiredTriggers: 1 - triggerCount: 0 - completed: false - failed: false - } - { - taskName: steps - description: Take your first steps - hint: Just start moving! - requiredTriggers: 1 - triggerCount: 1 - completed: true - failed: false - } - { - taskName: attack - description: Swing your first sword - hint: Just Attack! - requiredTriggers: 1 - triggerCount: 0 - completed: false - failed: false - } - ] - } - isSecretQuest: false - questDialogue: null - currentTaskIndex: 0 - isFailed: false - isActive: false - taskCompletionTriggers: null - } -] -} \ No newline at end of file