forked from pythonarcade/arcade
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix unneeded copies and
SpriteList
updates in physics engines (pyth…
…onarcade#2164) * Set .position instead of seperate center_x and center_y * Use itertools.chain instead of rebuilding lists * Update helper annotations to use Iterable instead of list * User itertools.chain to iterate over all obstacle SpriteLists instead of rebuilding lists * Add non-exhausting ListChain abstraction * Add ListChain in utils * Use it instead of itertools.chain * DRY physics engine list creation * Create _add_to_list local helper * Use it to add to created lists instead of repeated if logic * Stop re-creating lists in physics engines * Use .clear instead of overwiting lists * Use _add_to_list in PhysicsEngineSimple * Stop re-recreating the ListChain abstraction * Add an _all_obstacles field to PhysicsEnginePlatformer holding a ListChain * Use it when performing a jump or collision check instead of recreating a ListChain * Clean up imports * in physics engines * in utils * Document the components of ListChain * Generalize ListChain[_T] to Chain[_T] * Rename it * Allow arbitrary sequences rather than only lists * Update docstring * Revert some commit noise in utils * Run black formatter to make CI happy
- Loading branch information
Showing
2 changed files
with
67 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters