diff --git a/source/core/assets/images/lava_bg.png b/source/core/assets/images/lava_bg.png index 869b4c9a0..cca706805 100644 Binary files a/source/core/assets/images/lava_bg.png and b/source/core/assets/images/lava_bg.png differ diff --git a/source/core/src/main/com/csse3200/game/areas/terrain/TerrainFactory.java b/source/core/src/main/com/csse3200/game/areas/terrain/TerrainFactory.java index 2567da499..61723330c 100644 --- a/source/core/src/main/com/csse3200/game/areas/terrain/TerrainFactory.java +++ b/source/core/src/main/com/csse3200/game/areas/terrain/TerrainFactory.java @@ -23,7 +23,6 @@ import com.csse3200.game.screens.GameLevelData; import com.csse3200.game.services.ResourceService; import com.csse3200.game.services.ServiceLocator; - import static com.csse3200.game.screens.MainGameScreen.viewportHeight; import static com.csse3200.game.screens.MainGameScreen.viewportWidth; @@ -37,6 +36,7 @@ public class TerrainFactory { int selectedLevel = GameLevelData.getSelectedLevel(); private Texture whiteTexture; + /** * Create a terrain factory with Orthogonal orientation * @@ -48,7 +48,6 @@ public TerrainFactory(CameraComponent cameraComponent) { Viewport viewport = new ScreenViewport(camera); viewport.update(viewportWidth, viewportHeight, true); stage = new Stage(viewport, new SpriteBatch()); - camera.update(); Pixmap pixmap = new Pixmap(1, 1, Pixmap.Format.RGBA8888); @@ -108,9 +107,19 @@ private TiledMapRenderer createRenderer(TiledMap tiledMap, float tileScale) { private TiledMap createForestDemoTiles(GridPoint2 tileSize, TextureRegion grass) { TiledMap tiledMap = new TiledMap(); + /** + * Creates a background layer for a tiled map with the specified dimensions and tile size. + * + * @param width The width of the layer in tiles. + * @param height The height of the layer in tiles. + * @param tileWidth The width of each individual tile in pixels. + * @param tileHeight The height of each individual tile in pixels. + */ - // Create a background layer TiledMapTileLayer backgroundLayer = new TiledMapTileLayer(20, 8, tileSize.x, tileSize.y); + /** + * Define a TextureRegion to be used as the background texture. + */ TextureRegion backgroundTextureRegion ; switch (selectedLevel) { @@ -129,14 +138,30 @@ private TiledMap createForestDemoTiles(GridPoint2 tileSize, TextureRegion grass) break; } - // Create a single cell for the entire background image + /** + * Creates a single cell with the specified background texture region and adds it to the background layer + * of a tiled map. The background layer represents the entire background image of the map. + * + * @param backgroundTextureRegion The TextureRegion to use as the background texture. + * @param tileSizeX The width of each individual tile in pixels. + * @param tileSizeY The height of each individual tile in pixels. + * @param tiledMap The TiledMap to which the background layer should be added. + */ Cell cell = new Cell(); cell.setTile(new StaticTiledMapTile(backgroundTextureRegion)); backgroundLayer.setCell(0, 0, cell); tiledMap.getLayers().add(backgroundLayer); - // Create a grass layer + /** + * Creates a grass layer for the tiled map with the specified dimensions and tile size, filling it with + * grass tiles using the provided grass terrain tile. + * + * @param tileSizeX The width of each individual tile in pixels. + * @param tileSizeY The height of each individual tile in pixels. + * @param grassTile The TerrainTile representing the grass tile to be used for the layer. + * @param tiledMap The TiledMap to which the grass layer should be added. + */ TerrainTile grassTile = new TerrainTile(grass); TiledMapTileLayer grassLayer = new TiledMapTileLayer(20, 8, tileSize.x, tileSize.y); fillTiles(grassLayer, new GridPoint2(20, 8), grassTile); diff --git a/source/core/src/test/GameLevelDataTest.java b/source/core/src/test/GameLevelDataTest.java new file mode 100644 index 000000000..c9f6efcd2 --- /dev/null +++ b/source/core/src/test/GameLevelDataTest.java @@ -0,0 +1,30 @@ +import com.csse3200.game.screens.GameLevelData; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +class GameLevelDataTest { + + @Test + void shouldInitializeSelectedLevelToMinusOne() { + assertEquals(-1, GameLevelData.getSelectedLevel()); + } + + @Test + void shouldSetSelectedLevel() { + GameLevelData.setSelectedLevel(2); + assertEquals(2, GameLevelData.getSelectedLevel()); + } + + @Test + void shouldSetSelectedLevelToZero() { + GameLevelData.setSelectedLevel(0); + assertEquals(0, GameLevelData.getSelectedLevel()); + } + + @Test + void shouldSetSelectedLevelToNegativeValue() { + GameLevelData.setSelectedLevel(-5); + assertEquals(-5, GameLevelData.getSelectedLevel()); + } +}