Package sk.tuke.kpi.gamelib.map
Class TiledSceneMap
- java.lang.Object
-
- sk.tuke.kpi.gamelib.map.TiledSceneMap
-
- All Implemented Interfaces:
SceneMap
public final class TiledSceneMap extends java.lang.Object implements SceneMap
Map created with the Tiled map editor (https://https://www.mapeditor.org).Recognizes three special layers:
- **actors** - object layer with objects defining name, type and rectangle
(starting position) of an
Actor
. - **markers** - object layer with objects defining name and rectangle of markers in the scene.
- **walls** - tile layer, in which filled tiles define walls in the scene.
-
-
Field Summary
Fields Modifier and Type Field Description static @NotNull java.lang.String
ACTORS_LAYER_NAME
static int
COLLISION_PADDING
static @NotNull java.lang.String
MARKERS_LAYER_NAME
static @NotNull java.lang.String
WALLS_LAYER_NAME
-
Constructor Summary
Constructors Constructor Description TiledSceneMap(@NotNull java.lang.String mapResource, @NotNull Scene scene)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description @NotNull java.util.Collection<ActorMapObject>
getActorObjects()
int
getGridHeight()
int
getGridWidth()
@NotNull java.lang.String
getMapResource()
@NotNull java.util.Map<java.lang.String,MapMarker>
getMarkers()
@NotNull Overlay
getOverlay()
@NotNull MapTile
getTile(int tileX, int tileY)
Gets a tile at specified grid position.int
getTileHeight()
int
getTileWidth()
boolean
intersectsWithWall(@NotNull Actor actor)
void
render(float deltaTime)
Renders the map.
-
-
-
Field Detail
-
ACTORS_LAYER_NAME
@NotNull public static final @NotNull java.lang.String ACTORS_LAYER_NAME
- See Also:
- Constant Field Values
-
MARKERS_LAYER_NAME
@NotNull public static final @NotNull java.lang.String MARKERS_LAYER_NAME
- See Also:
- Constant Field Values
-
WALLS_LAYER_NAME
@NotNull public static final @NotNull java.lang.String WALLS_LAYER_NAME
- See Also:
- Constant Field Values
-
COLLISION_PADDING
public static final int COLLISION_PADDING
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
TiledSceneMap
public TiledSceneMap(@NotNull @NotNull java.lang.String mapResource, @NotNull @NotNull Scene scene)
-
-
Method Detail
-
getMapResource
@NotNull public @NotNull java.lang.String getMapResource()
-
getGridWidth
public int getGridWidth()
- Specified by:
getGridWidth
in interfaceSceneMap
- Returns:
- width of the map tile grid (unit: tile)
-
getGridHeight
public int getGridHeight()
- Specified by:
getGridHeight
in interfaceSceneMap
- Returns:
- height of the map tile grid (unit: tile)
-
getTileWidth
public int getTileWidth()
- Specified by:
getTileWidth
in interfaceSceneMap
- Returns:
- width of a single tile (unit: pixel)
-
getTileHeight
public int getTileHeight()
- Specified by:
getTileHeight
in interfaceSceneMap
- Returns:
- height of a single tile (unit: pixel)
-
getActorObjects
@NotNull public @NotNull java.util.Collection<ActorMapObject> getActorObjects()
- Specified by:
getActorObjects
in interfaceSceneMap
- Returns:
actor objects
defined by the map
-
getMarkers
@NotNull public @NotNull java.util.Map<java.lang.String,MapMarker> getMarkers()
- Specified by:
getMarkers
in interfaceSceneMap
- Returns:
map markers
mapped by theirnames
-
getOverlay
@NotNull public @NotNull Overlay getOverlay()
- Specified by:
getOverlay
in interfaceSceneMap
- Returns:
- map overlay layer
-
getTile
@NotNull public @NotNull MapTile getTile(int tileX, int tileY)
Description copied from interface:SceneMap
Gets a tile at specified grid position.
-
intersectsWithWall
public boolean intersectsWithWall(@NotNull @NotNull Actor actor)
- Specified by:
intersectsWithWall
in interfaceSceneMap
- Parameters:
actor
- actor to check for intersection- Returns:
- true if the specified actor intersects with a wall in the map
-
-