Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions arcade/tilemap/tilemap.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
from arcade.texture.loading import _load_tilemap_texture

if TYPE_CHECKING:
from arcade import TextureAtlas
from arcade import TextureAtlas, Texture

from pyglet.math import Vec2

Expand Down Expand Up @@ -102,6 +102,16 @@ def _get_image_source(
return None


def _may_be_flip(tile: pytiled_parser.Tile, texture: Texture) -> Texture:
if tile.flipped_diagonally:
texture = texture.flip_diagonally()
if tile.flipped_horizontally:
texture = texture.flip_horizontally()
if tile.flipped_vertically:
texture = texture.flip_vertically()
return texture


class TileMap:
"""
Class that represents a fully parsed and loaded map from Tiled.
Expand Down Expand Up @@ -466,12 +476,7 @@ def _create_sprite_from_tile(
height=height,
hit_box_algorithm=hit_box_algorithm,
)
if tile.flipped_diagonally:
texture = texture.flip_diagonally()
if tile.flipped_horizontally:
texture = texture.flip_horizontally()
if tile.flipped_vertically:
texture = texture.flip_vertically()
texture = _may_be_flip(tile, texture)

args = {
"path_or_texture": texture, # type: ignore
Expand Down Expand Up @@ -625,6 +630,8 @@ def _create_sprite_from_tile(
f"tile '{frame_tile.id}', '{image_file}'."
)

texture = _may_be_flip(tile, texture)

key_frame = AnimationKeyframe( # type: ignore
frame.tile_id, frame.duration, texture
)
Expand Down