Package com.csse3200.game.areas.terrain
Class TerrainFactory
java.lang.Object
com.csse3200.game.areas.terrain.TerrainFactory
Factory for creating game terrains.
-
Field Summary
FieldsModifier and TypeFieldDescriptionHashMap used to map characters in map files to file paths containing their texturesprotected static final String
The file path for the SpaceGameArea map filestatic final float
The tile size constant used for each tile in the TiledMap class -
Constructor Summary
ConstructorsConstructorDescriptionTerrainFactory
(CameraComponent cameraComponent) Create a terrain factory with Orthogonal orientation.TerrainFactory
(CameraComponent cameraComponent, TerrainComponent.TerrainOrientation orientation) Create a terrain factory -
Method Summary
Modifier and TypeMethodDescriptioncreateSpaceGameTerrain
(com.badlogic.gdx.maps.tiled.TiledMap tiledMap) Initiates the create terrain process for the SpaceGameArea.createTestTerrain
(com.badlogic.gdx.maps.tiled.TiledMap tiledMap, String testMapFilePath) Initiates the create terrain process for play testing different maps.com.badlogic.gdx.math.GridPoint2
Returns a copy of the MAP_SIZE variable.static String[]
static boolean
This function will be used to check if a string is numeric.void
Loads textures into the charToTextureMap based upon the images within the charToTileImageMap and resourceService.void
loadTiledMap
(com.badlogic.gdx.maps.tiled.TiledMap tiledMap, String mapFilePath) Finishes the create terrain process, loading the map into the TiledMap instance.
-
Field Details
-
WORLD_TILE_SIZE
public static final float WORLD_TILE_SIZEThe tile size constant used for each tile in the TiledMap class- See Also:
-
MAP_PATH
The file path for the SpaceGameArea map file- See Also:
-
charToTileImageMap
HashMap used to map characters in map files to file paths containing their textures
-
-
Constructor Details
-
TerrainFactory
Create a terrain factory with Orthogonal orientation.- Parameters:
cameraComponent
- Camera to render terrains to. Must be orthographic.
-
TerrainFactory
public TerrainFactory(CameraComponent cameraComponent, TerrainComponent.TerrainOrientation orientation) Create a terrain factory- Parameters:
cameraComponent
- Camera to render terrains to. Must be orthographic.orientation
- orientation to render terrain at.
-
-
Method Details
-
getMapTextures
-
isNumeric
This function will be used to check if a string is numeric.- Parameters:
strNum
- the string to be checked.- Returns:
- false if the string is not numeric, else return true.
-
loadTextures
public void loadTextures()Loads textures into the charToTextureMap based upon the images within the charToTileImageMap and resourceService. -
getMapSize
public com.badlogic.gdx.math.GridPoint2 getMapSize()Returns a copy of the MAP_SIZE variable.- Returns:
- GridPoint2 instance representing Map Size.
-
createSpaceGameTerrain
Initiates the create terrain process for the SpaceGameArea.- Parameters:
tiledMap
- the TiledMap instance of the game map.- Returns:
- Terrain component which renders the terrain.
-
createTestTerrain
public TerrainComponent createTestTerrain(com.badlogic.gdx.maps.tiled.TiledMap tiledMap, String testMapFilePath) Initiates the create terrain process for play testing different maps.- Parameters:
tiledMap
- the TiledMap instance of the test game map.testMapFilePath
- the file path of the test map file to be loaded.- Returns:
- Terrain component which renders the terrain.
-
loadTiledMap
Finishes the create terrain process, loading the map into the TiledMap instance.- Parameters:
tiledMap
- the TiledMap instance of the test game map.mapFilePath
- the file path of the map file to be loaded.
-