Skip to content

Commit

Permalink
Added java doc
Browse files Browse the repository at this point in the history
  • Loading branch information
Moksh-Mehta7 committed Sep 11, 2023
1 parent ae5eb56 commit 6b09529
Showing 1 changed file with 29 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,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) {
Expand All @@ -129,14 +139,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);
Expand Down

0 comments on commit 6b09529

Please sign in to comment.