Package com.deco2800.game.areas.terrain
Class TerrainComponent
java.lang.Object
com.deco2800.game.components.Component
com.deco2800.game.rendering.RenderComponent
com.deco2800.game.areas.terrain.TerrainComponent
- All Implemented Interfaces:
Disposable
,Renderable
,java.lang.Comparable<Renderable>
public class TerrainComponent extends RenderComponent
Render a tiled terrain for a given tiled map and orientation. A terrain is a map of tiles that
shows the 'ground' in the game. Enabling/disabling this component will show/hide the terrain.
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
TerrainComponent.TerrainOrientation
-
Field Summary
-
Constructor Summary
Constructors Constructor Description TerrainComponent(OrthographicCamera camera, TiledMap map, TiledMapRenderer renderer, TerrainComponent.TerrainOrientation orientation, float tileSize)
-
Method Summary
Modifier and Type Method Description void
dispose()
Called when the component is disposed.void
draw(SpriteBatch batch)
Draw the renderable.int
getLayer()
Layer to be rendered in.TiledMap
getMap()
GridPoint2
getMapBounds(int layer)
float
getTileSize()
float
getZIndex()
Set the zIndex of the entity according to the y coordinate of the entity and the original zIndex.Vector2
tileToWorldPosition(int x, int y)
Vector2
tileToWorldPosition(GridPoint2 tilePos)
Methods inherited from class com.deco2800.game.components.Component
earlyUpdate, getEntity, setEnabled, setEntity, toString, triggerEarlyUpdate, triggerUpdate, update
-
Constructor Details
-
TerrainComponent
public TerrainComponent(OrthographicCamera camera, TiledMap map, TiledMapRenderer renderer, TerrainComponent.TerrainOrientation orientation, float tileSize)
-
-
Method Details
-
tileToWorldPosition
-
tileToWorldPosition
-
getTileSize
public float getTileSize() -
getMapBounds
-
getMap
-
draw
Description copied from class:RenderComponent
Draw the renderable. Should be called only by the renderer, not manually.- Specified by:
draw
in classRenderComponent
- Parameters:
batch
- Batch to render to.
-
dispose
public void dispose()Description copied from class:Component
Called when the component is disposed. Dispose of any internal resources here.- Specified by:
dispose
in interfaceDisposable
- Overrides:
dispose
in classRenderComponent
-
getZIndex
public float getZIndex()Description copied from class:RenderComponent
Set the zIndex of the entity according to the y coordinate of the entity and the original zIndex. If zIndex is not set originally, then The smaller the Y value, the higher the Z index, so that closer entities are drawn in front. If zIndex has been set, zIndex will not change.- Specified by:
getZIndex
in interfaceRenderable
- Overrides:
getZIndex
in classRenderComponent
- Returns:
- The drawing priority of the current entity
-
getLayer
public int getLayer()Description copied from interface:Renderable
Layer to be rendered in. Higher layers will be rendered on top of lower layers.- Specified by:
getLayer
in interfaceRenderable
- Overrides:
getLayer
in classRenderComponent
- Returns:
- layer
-