public class MapTileGame extends FeaturableModel implements MapTile
SpriteTiled
), and collisions.
The way to prepare a map is the following:
create(int, int, int, int)
// prepare memory to store tilesloadSheets(Media)
// load tile sheets
Or import a map from a level rip with create(Media, Media)
.
Tile
Constructor and Description |
---|
MapTileGame()
Create a map tile.
|
Modifier and Type | Method and Description |
---|---|
void |
addListener(TileSetListener listener)
Add a tile set listener.
|
void |
append(Collection<MapTile> maps,
int offsetX,
int offsetY,
int randX,
int randY)
Append existing maps.
|
void |
append(MapTile map,
int offsetX,
int offsetY)
Append an existing map, starting at the specified offsets.
|
void |
clear()
Remove all tiles from map and clear internal data.
|
void |
create(int tileWidth,
int tileHeight,
int widthInTile,
int heightInTile)
Create and prepare map memory area.
|
void |
create(Media levelrip)
Create a map from a level rip which should be an image file (*.PNG, *.BMP) that represents the full map.
|
void |
create(Media levelrip,
int tileWidth,
int tileHeight,
int horizontalTiles)
Create a map from a level rip which should be an image file (*.PNG, *.BMP) that represents the full map.
|
void |
create(Media levelrip,
Media sheetsConfig)
Create a map from a level rip and the associated tiles configuration file.
|
Tile |
createTile(Integer sheet,
int number,
double x,
double y)
Create a tile.
|
int |
getHeight() |
int |
getInTileHeight()
Get number of vertical tiles.
|
int |
getInTileRadius()
Get the radius in tile.
|
int |
getInTileWidth()
Get number of horizontal tiles.
|
int |
getInTileX(Localizable localizable)
Get location x relative to map referential as tile.
|
int |
getInTileY(Localizable localizable)
Get location y relative to map referential as tile.
|
Media |
getMedia()
Get the associated media.
|
Collection<Tile> |
getNeighbors(Tile tile)
Get the tile neighbor, directly adjacent to it.
|
SpriteTiled |
getSheet(Integer sheet)
Get sheet from its id.
|
Collection<Integer> |
getSheets()
Get list of sheets id.
|
int |
getSheetsNumber()
Get the number of used sheets.
|
Tile |
getTile(int tx,
int ty)
Get tile from specified map location (in tile index).
|
Tile |
getTile(Localizable localizable,
int offsetX,
int offsetY)
Get the tile at the localizable.
|
Tile |
getTileAt(double x,
double y)
Get the tile at the location.
|
int |
getTileHeight() |
Collection<Tile> |
getTilesHit(double ox,
double oy,
double x,
double y)
Get the list of tiles from old location to current.
|
int |
getTilesNumber()
Get number of active tiles (which are not
null ). |
int |
getTileWidth() |
int |
getWidth() |
boolean |
isCreated()
Check if map has been created.
|
void |
loadSheets(Collection<SpriteTiled> sheets)
Load map sheets (tiles surfaces).
|
void |
loadSheets(Media sheetsConfig)
Load map sheets (tiles surfaces) from directory.
|
void |
removeListener(TileSetListener listener)
Remove a tile set listener.
|
void |
setTile(Tile tile)
Set a tile at specified map location.
|
addFeature, addFeatureAndGet, checkListener, clearCache, getFeature, getFeatures, getFeaturesType, hasFeature
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addFeature, addFeatureAndGet, checkListener
getFeature, getFeatures, getFeaturesType, hasFeature
public void create(int tileWidth, int tileHeight, int widthInTile, int heightInTile)
MapTile
MapTile.setTile(Tile)
).
Previous map data (if existing) will be cleared (MapTile.clear()
).create
in interface MapTile
tileWidth
- The tile width.tileHeight
- The tile height.widthInTile
- The map width in tile (must be strictly positive).heightInTile
- The map height in tile (must be strictly positive).MapTile.create(Media)
,
MapTile.create(Media, Media)
public Tile createTile(Integer sheet, int number, double x, double y)
MapTile
createTile
in interface MapTile
sheet
- The sheet number (must be positive or equal to 0).number
- The tile number on sheet (must be positive or equal to 0).x
- The horizontal location.y
- The vertical location.public void create(Media levelrip, int tileWidth, int tileHeight, int horizontalTiles)
MapTile
MapTile.create(int, int, int, int)
).create
in interface MapTile
levelrip
- The file describing the levelrip as a single image.tileWidth
- The tile width.tileHeight
- The tile height.horizontalTiles
- The number of horizontal tiles on sheets.TilesExtractor
,
LevelRipConverter
public void create(Media levelrip)
MapTile
MapTile.create(int, int, int, int)
).
TileSheetsConfig.FILENAME
and TileGroupsConfig.FILENAME
will be used as default, by calling MapTile.create(Media, Media)
.
create
in interface MapTile
levelrip
- The file describing the levelrip as a single image.TilesExtractor
,
LevelRipConverter
public void create(Media levelrip, Media sheetsConfig)
MapTile
MapTile.create(int, int, int, int)
).create
in interface MapTile
levelrip
- The file describing the levelrip as a single image.sheetsConfig
- The file that define the sheets configuration.TilesExtractor
,
LevelRipConverter
public void loadSheets(Collection<SpriteTiled> sheets)
MapTile
loadSheets
in interface MapTile
sheets
- The sheets reference.public void loadSheets(Media sheetsConfig)
MapTile
loadSheets
in interface MapTile
sheetsConfig
- The file that define the sheets configuration.public void append(MapTile map, int offsetX, int offsetY)
MapTile
MapTile.append(MapTile, int, int)
at (MapTile.getInTileWidth()
, MapTile.getInTileHeight()
) will add
the new map at the top-right.public void append(Collection<MapTile> maps, int offsetX, int offsetY, int randX, int randY)
MapTile
public void clear()
MapTile
MapTile.loadSheets(Media)
).public void addListener(TileSetListener listener)
MapTile
addListener
in interface MapTile
listener
- The listener reference.public void removeListener(TileSetListener listener)
MapTile
removeListener
in interface MapTile
listener
- The listener reference.public void setTile(Tile tile)
MapTile
The tile location must be between 0 and map size (MapTile.getInTileWidth()
, MapTile.getInTileHeight()
).
If a tile exists at the tile location, it will be removed.
public Tile getTile(int tx, int ty)
MapTile
null
, this
means that there is not tile at this location. It is not an error, just a way to avoid useless tile storage.public Tile getTile(Localizable localizable, int offsetX, int offsetY)
MapTile
public Tile getTileAt(double x, double y)
MapTile
public Collection<Tile> getNeighbors(Tile tile)
MapTile
getNeighbors
in interface MapTile
tile
- The tile reference.public Collection<Tile> getTilesHit(double ox, double oy, double x, double y)
MapTile
getTilesHit
in interface MapTile
ox
- The old horizontal location.oy
- The old vertical location.x
- The current horizontal location.y
- The current vertical location.public int getInTileX(Localizable localizable)
MapTile
getInTileX
in interface MapTile
localizable
- The localizable reference.public int getInTileY(Localizable localizable)
MapTile
getInTileY
in interface MapTile
localizable
- The localizable reference.public Media getMedia()
Featurable
getMedia
in interface Featurable
getMedia
in class FeaturableModel
null
if none.public Collection<Integer> getSheets()
MapTile
public SpriteTiled getSheet(Integer sheet)
MapTile
public int getSheetsNumber()
MapTile
getSheetsNumber
in interface MapTile
public int getTilesNumber()
MapTile
null
).getTilesNumber
in interface MapTile
null
tile.public int getTileWidth()
getTileWidth
in interface SurfaceTile
public int getTileHeight()
getTileHeight
in interface SurfaceTile
public int getInTileWidth()
MapTile
getInTileWidth
in interface MapTile
public int getInTileHeight()
MapTile
getInTileHeight
in interface MapTile
public int getInTileRadius()
MapTile
getInTileRadius
in interface MapTile
public boolean isCreated()
MapTile
Copyright © 2017 Byron 3D Games Studio. All rights reserved.