Package bagel.map
Class TiledMap
java.lang.Object
bagel.map.TiledMap
Loads a tile map as produced by Tiled Map Editor.
Allows looking up properties of tiles in the map as well as basic rendering.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddraw(double windowX, double windowY, double mapX, double mapY, double width, double height) Draws the rectangular region of the map with top left at (mapX, mapY) and bottom right at (mapX + width, mapY + height).Returns all polylines associated with this map.intReturns the height of the entire map, in pixels.getProperty(int x, int y, String property) Returns the string value of the provided property at the given (x, y) pixel coordinate of the map.getProperty(int x, int y, String property, String defaultValue) Returns the string value of the provided property at the given (x, y) pixel coordinate of the map.booleangetPropertyBoolean(int x, int y, String property, boolean defaultValue) Returns the Boolean value of the provided property at the given (x, y) pixel coordinate of the map.doublegetPropertyDouble(int x, int y, String property, double defaultValue) Returns the double value of the provided property at the given (x, y) pixel coordinate of the map.intgetPropertyInt(int x, int y, String property, int defaultValue) Returns the integer value of the provided property at the given (x, y) pixel coordinate of the map.intReturns the height of an individual tile in the map, in pixels.intReturns the width of an individual tile in the map, in pixels.intgetWidth()Returns the width of the entire map, in pixels.booleanhasProperty(int x, int y, String property) Returns true if the tile at the given (x, y) pixel coordinate of the map has the given property.
-
Constructor Details
-
TiledMap
Build the tiled map from the provided .tmx file.
-
-
Method Details
-
getTileWidth
public int getTileWidth()Returns the width of an individual tile in the map, in pixels. -
getTileHeight
public int getTileHeight()Returns the height of an individual tile in the map, in pixels. -
getWidth
public int getWidth()Returns the width of the entire map, in pixels. -
getHeight
public int getHeight()Returns the height of the entire map, in pixels. -
getProperty
Returns the string value of the provided property at the given (x, y) pixel coordinate of the map. -
getProperty
Returns the string value of the provided property at the given (x, y) pixel coordinate of the map.If the property is missing, returns the default.
-
getPropertyInt
Returns the integer value of the provided property at the given (x, y) pixel coordinate of the map. If the value is not a valid integer, throwsBagelError.defaultValue is the value that will be returned if the tile has no such property.
-
getPropertyDouble
Returns the double value of the provided property at the given (x, y) pixel coordinate of the map. If the value is not a valid double, throwsBagelError.defaultValue is the value that will be returned if the tile has no such property.
-
getPropertyBoolean
Returns the Boolean value of the provided property at the given (x, y) pixel coordinate of the map. If the value is not a valid boolean, throwsBagelError.defaultValue is the value that will be returned if the tile has no such property.
-
hasProperty
Returns true if the tile at the given (x, y) pixel coordinate of the map has the given property. -
getAllPolylines
Returns all polylines associated with this map. A polyline is simply a list of points.- Returns:
- List of polylines
-
draw
public void draw(double windowX, double windowY, double mapX, double mapY, double width, double height) Draws the rectangular region of the map with top left at (mapX, mapY) and bottom right at (mapX + width, mapY + height). The top left will be drawn on the window at (windowX, windowY).- Parameters:
windowX- The x coordinate of the window to start drawing the map region fromwindowY- The y coordinate of the window to start drawing the map region frommapX- The x coordinate of the map to start drawing frommapY- The y coordinate of the map to start drawing fromwidth- The width of the region to renderheight- The height of the region to render
-