diff --git a/arcade/sprite_list/sprite_list.py b/arcade/sprite_list/sprite_list.py index 26f0586d3..cce2cf95c 100644 --- a/arcade/sprite_list/sprite_list.py +++ b/arcade/sprite_list/sprite_list.py @@ -93,7 +93,7 @@ class SpriteList(Generic[SpriteType]): def __init__( self, - use_spatial_hash: Optional[bool] = None, + use_spatial_hash: bool = False, spatial_hash_cell_size: int = 128, atlas: Optional["TextureAtlas"] = None, capacity: int = 100, @@ -156,7 +156,7 @@ def __init__( self._spatial_hash_cell_size = spatial_hash_cell_size self.spatial_hash: Optional[SpatialHash] = None - if use_spatial_hash is True: + if use_spatial_hash: self.spatial_hash = SpatialHash(cell_size=self._spatial_hash_cell_size) self.properties: Optional[Dict[str, Any]] = None diff --git a/arcade/tilemap/tilemap.py b/arcade/tilemap/tilemap.py index c8fa71182..9d86e2708 100644 --- a/arcade/tilemap/tilemap.py +++ b/arcade/tilemap/tilemap.py @@ -108,7 +108,7 @@ class TileMap: :param Union[str, Path] map_file: A JSON map file for a Tiled map to initialize from :param float scaling: Global scaling to apply to all Sprites. :param Dict[str, Dict[str, Any]] layer_options: Extra parameters for each layer. - :param Optional[bool] use_spatial_hash: If set to True, this will make moving a sprite + :param bool use_spatial_hash: If set to True, this will make moving a sprite in the SpriteList slower, but it will speed up collision detection with items in the SpriteList. Great for doing collision detection with static walls/platforms. @@ -179,7 +179,7 @@ def __init__( map_file: Union[str, Path] = "", scaling: float = 1.0, layer_options: Optional[Dict[str, Dict[str, Any]]] = None, - use_spatial_hash: Optional[bool] = None, + use_spatial_hash: bool = False, hit_box_algorithm: Optional[HitBoxAlgorithm] = None, tiled_map: Optional[pytiled_parser.TiledMap] = None, offset: Vec2 = Vec2(0, 0), @@ -626,7 +626,7 @@ def _process_image_layer( layer: pytiled_parser.ImageLayer, texture_atlas: "TextureAtlas", scaling: float = 1.0, - use_spatial_hash: Optional[bool] = None, + use_spatial_hash: bool = False, hit_box_algorithm: Optional[HitBoxAlgorithm] = None, offset: Vec2 = Vec2(0, 0), custom_class: Optional[type] = None, @@ -717,7 +717,7 @@ def _process_tile_layer( layer: pytiled_parser.TileLayer, texture_atlas: "TextureAtlas", scaling: float = 1.0, - use_spatial_hash: Optional[bool] = None, + use_spatial_hash: bool = False, hit_box_algorithm: Optional[HitBoxAlgorithm] = None, offset: Vec2 = Vec2(0, 0), custom_class: Optional[type] = None, @@ -792,7 +792,7 @@ def _process_object_layer( layer: pytiled_parser.ObjectLayer, texture_atlas: "TextureAtlas", scaling: float = 1.0, - use_spatial_hash: Optional[bool] = None, + use_spatial_hash: bool = False, hit_box_algorithm: Optional[HitBoxAlgorithm] = None, offset: Vec2 = Vec2(0, 0), custom_class: Optional[type] = None, @@ -984,7 +984,7 @@ def load_tilemap( map_file: Union[str, Path], scaling: float = 1.0, layer_options: Optional[Dict[str, Dict[str, Any]]] = None, - use_spatial_hash: Optional[bool] = None, + use_spatial_hash: bool = False, hit_box_algorithm: Optional[HitBoxAlgorithm] = None, offset: Vec2 = Vec2(0, 0), texture_atlas: Optional["TextureAtlas"] = None, @@ -1001,7 +1001,7 @@ def load_tilemap( :param Union[str, Path] map_file: The JSON map file. :param float scaling: The global scaling to apply to all Sprite's within the map. - :param Optional[bool] use_spatial_hash: If set to True, this will make moving a sprite + :param bool use_spatial_hash: If set to True, this will make moving a sprite in the SpriteList slower, but it will speed up collision detection with items in the SpriteList. Great for doing collision detection with static walls/platforms. diff --git a/doc/programming_guide/release_notes.rst b/doc/programming_guide/release_notes.rst index d1803725f..bd75fd072 100644 --- a/doc/programming_guide/release_notes.rst +++ b/doc/programming_guide/release_notes.rst @@ -47,6 +47,7 @@ API in a way that is not compatible with how it was used in 2.6. are also using any custom :py:class:`~arcade.TextureAtlas`. * The GUI package has been changed significantly. * Buffered shapes (shape list items) have been moved to their own sub-module. +* `use_spatial_hash` parameter for `SpriteList` and `TileMap` is now a `bool` instead of `Optional[bool]` Featured Updates ~~~~~~~~~~~~~~~~ @@ -2349,4 +2350,3 @@ Enhancements * `Issue 131 `_: Add example code on how to do full-screen games * `Issue 113 `_: Add example code showing enemy turning around when hitting a wall * `Issue 67 `_: Improved support and documentation for joystick/game controllers -