def __init__(self, layer, pytmx_tiled_map, id_, tile_props, rect):
"""
:param TiledTileLayer layer: the TiledTileLayer object to which this tile belongs
:param pytmx.pytmx.TiledMap pytmx_tiled_map: the tmx tiled-map object to which this tile belongs
(useful to have to look up certain map-side properties, e.g. tilewidth/height)
:param int id_: tthe ID of the tile in the layer
:param dict tile_props: the properties dict of this tile (values already translated into python types)
:param Union[pygame.Rect,None] rect: the pygame.Rect representing the position and size of the tile
"""
super().__init__(layer, pytmx_tiled_map, id_, tile_props, rect)
# slope properties of the tile
self.slope = tile_props.get("slope", None) # the slope property of the tile in the tmx file (inverse steepness (1/m in y=mx+b) of the line that defines the slope)
self.offset = tile_props.get("offset", None) # the offset property of the tile in the tmx file (in px (b in y=mx+b))
self.is_full = (self.slope == 0.0 and self.offset == 1.0) # is this a full collision tile?
self.max_x = self.pytmx_tiled_map.tilewidth
self.max_y = max(self.get_y(0), self.get_y(self.rect.width)) # store our highest y-value (height of this tile)
评论列表
文章目录