diff --git a/source/core/assets/images/ingamebg.png b/source/core/assets/images/ingamebg.png new file mode 100644 index 000000000..0fbc1c543 Binary files /dev/null and b/source/core/assets/images/ingamebg.png differ diff --git a/source/core/src/main/com/csse3200/game/areas/ForestGameArea.java b/source/core/src/main/com/csse3200/game/areas/ForestGameArea.java index 7d3d97ef2..a2261d154 100644 --- a/source/core/src/main/com/csse3200/game/areas/ForestGameArea.java +++ b/source/core/src/main/com/csse3200/game/areas/ForestGameArea.java @@ -54,6 +54,7 @@ public class ForestGameArea extends GameArea { // Required to load assets before using them private static final String[] forestTextures = { + "images/ingamebg.png", "images/projectiles/projectile.png", "images/box_boy_leaf.png", "images/background/building1.png", 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 5f1c997f6..6ebf18a49 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 @@ -11,6 +11,7 @@ import com.badlogic.gdx.maps.tiled.TiledMapTileLayer; import com.badlogic.gdx.maps.tiled.TiledMapTileLayer.Cell; import com.badlogic.gdx.maps.tiled.renderers.OrthogonalTiledMapRenderer; +import com.badlogic.gdx.maps.tiled.tiles.StaticTiledMapTile; import com.badlogic.gdx.math.GridPoint2; import com.badlogic.gdx.scenes.scene2d.Stage; import com.badlogic.gdx.scenes.scene2d.ui.TextButton; @@ -98,19 +99,34 @@ private TiledMapRenderer createRenderer(TiledMap tiledMap, float tileScale) { } } - private TiledMap createForestDemoTiles( - GridPoint2 tileSize, TextureRegion grass) { + private TiledMap createForestDemoTiles(GridPoint2 tileSize, TextureRegion grass) { TiledMap tiledMap = new TiledMap(); - TerrainTile grassTile = new TerrainTile(grass); - TiledMapTileLayer layer = new TiledMapTileLayer(MAP_SIZE.x, MAP_SIZE.y, tileSize.x, tileSize.y); - // Create base grass - fillTiles(layer, MAP_SIZE, grassTile); + // Create a background layer + TiledMapTileLayer backgroundLayer = new TiledMapTileLayer(20, 8, tileSize.x, tileSize.y); + TextureRegion backgroundTextureRegion = new TextureRegion(ServiceLocator.getResourceService().getAsset("images/ingamebg.png", Texture.class)); + + // Create a single cell for the entire background image + Cell cell = new Cell(); + cell.setTile(new StaticTiledMapTile(backgroundTextureRegion)); + backgroundLayer.setCell(0, 0, cell); + + tiledMap.getLayers().add(backgroundLayer); + + // Create a grass layer + TerrainTile grassTile = new TerrainTile(grass); + TiledMapTileLayer grassLayer = new TiledMapTileLayer(20, 8, tileSize.x, tileSize.y); + fillTiles(grassLayer, new GridPoint2(20, 8), grassTile); + tiledMap.getLayers().add(grassLayer); - tiledMap.getLayers().add(layer); return tiledMap; } + + + + + private static void fillTiles(TiledMapTileLayer layer, GridPoint2 mapSize, TerrainTile tile) { BitmapFont font = new BitmapFont(); TextButton.TextButtonStyle textButtonStyle = new TextButton.TextButtonStyle();