From abe755cd90c70102a895dfb61eee887e5110575b Mon Sep 17 00:00:00 2001 From: Darren Eberly Date: Sun, 19 Feb 2023 16:20:40 -0500 Subject: [PATCH 1/2] Make tilemap texture loading respect hitbox algorithm switch --- arcade/tilemap/tilemap.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arcade/tilemap/tilemap.py b/arcade/tilemap/tilemap.py index c85b077729..f5f73e2a2e 100644 --- a/arcade/tilemap/tilemap.py +++ b/arcade/tilemap/tilemap.py @@ -442,7 +442,7 @@ def _create_sprite_from_tile( # Can image_file be None? image_x, image_y, width, height = _get_image_info_from_tileset(tile) - texture = load_texture(image_file, x=image_x, y=image_y, width=width, height=height) # type: ignore + texture = load_texture(image_file, x=image_x, y=image_y, width=width, height=height, hit_box_algorithm=hit_box_algorithm) # type: ignore if tile.flipped_diagonally: texture = texture.flip_diagonally() if tile.flipped_horizontally: @@ -569,7 +569,7 @@ def _create_sprite_from_tile( image_file = _get_image_source(frame_tile, map_directory) if not frame_tile.tileset.image and image_file: - texture = load_texture(image_file) + texture = load_texture(image_file, hit_box_algorithm=hit_box_algorithm) elif image_file: # No image for tile, pull from tilesheet ( @@ -580,7 +580,7 @@ def _create_sprite_from_tile( ) = _get_image_info_from_tileset(frame_tile) texture = load_texture( - image_file, x=image_x, y=image_y, width=width, height=height + image_file, x=image_x, y=image_y, width=width, height=height, hit_box_algorithm=hit_box_algorithm ) else: raise RuntimeError( From e03e2710f8df469c722da4a16f545313e0eec4e1 Mon Sep 17 00:00:00 2001 From: Darren Eberly Date: Sun, 19 Feb 2023 16:31:53 -0500 Subject: [PATCH 2/2] Formatting fixes --- arcade/tilemap/tilemap.py | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/arcade/tilemap/tilemap.py b/arcade/tilemap/tilemap.py index f5f73e2a2e..4032e55f59 100644 --- a/arcade/tilemap/tilemap.py +++ b/arcade/tilemap/tilemap.py @@ -12,7 +12,7 @@ import os from collections import OrderedDict from pathlib import Path -from typing import Any, Dict, List, Optional, Tuple, TYPE_CHECKING, Union, cast +from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Union, cast import pytiled_parser import pytiled_parser.tiled_object @@ -30,10 +30,11 @@ if TYPE_CHECKING: from arcade import TextureAtlas -from arcade.types import Point, TiledObject +from pyglet.math import Vec2 + from arcade.geometry_generic import rotate_point from arcade.resources import resolve_resource_path -from pyglet.math import Vec2 +from arcade.types import Point, TiledObject _FLIPPED_HORIZONTALLY_FLAG = 0x80000000 _FLIPPED_VERTICALLY_FLAG = 0x40000000 @@ -442,7 +443,14 @@ def _create_sprite_from_tile( # Can image_file be None? image_x, image_y, width, height = _get_image_info_from_tileset(tile) - texture = load_texture(image_file, x=image_x, y=image_y, width=width, height=height, hit_box_algorithm=hit_box_algorithm) # type: ignore + texture = load_texture( + image_file, # type: ignore + x=image_x, + y=image_y, + width=width, + height=height, + hit_box_algorithm=hit_box_algorithm + ) if tile.flipped_diagonally: texture = texture.flip_diagonally() if tile.flipped_horizontally: @@ -569,7 +577,10 @@ def _create_sprite_from_tile( image_file = _get_image_source(frame_tile, map_directory) if not frame_tile.tileset.image and image_file: - texture = load_texture(image_file, hit_box_algorithm=hit_box_algorithm) + texture = load_texture( + image_file, + hit_box_algorithm=hit_box_algorithm + ) elif image_file: # No image for tile, pull from tilesheet ( @@ -580,7 +591,12 @@ def _create_sprite_from_tile( ) = _get_image_info_from_tileset(frame_tile) texture = load_texture( - image_file, x=image_x, y=image_y, width=width, height=height, hit_box_algorithm=hit_box_algorithm + image_file, + x=image_x, + y=image_y, + width=width, + height=height, + hit_box_algorithm=hit_box_algorithm ) else: raise RuntimeError(