Conversation
get_collision_info_with_list(sprite, sprite_list, method=AUTO) returns a (sprite, CollisionInfo) pair for each colliding sprite in the list, deepest overlap first. It finds the same sprites as check_for_collision_with_list and each CollisionInfo matches get_collision_info. Split get_collision_info into the public function and an internal one without the argument checks, for the list loop. Add the sprite_push_out example: the player moves freely and is pushed out of the deepest overlapping wall after each update, sliding along rotated walls. Add its docs page, screenshot, and an entry in the example index under Player Movement. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
PR 2 of the push-out plan, following
get_collision_info(#2910):arcade.get_collision_info_with_list(sprite, sprite_list, method=AUTO)returns a(colliding_sprite, CollisionInfo)pair for each sprite in the list thatspritecollides with, deepest overlap first.sprite_push_out, with a docs page.get_collision_info_with_listcheck_for_collision_with_list, using the sameCollisionMethodchoice (spatial hash, every sprite, or GPU), and never includesspriteitself.CollisionInfois exactly whatget_collision_info(sprite, that_sprite)returns.get_collision_infois split into the public function (type checks) and an internal_get_collision_info, so the list version doesn't repeat the checks for every sprite. Its behavior is unchanged.The example
The player moves freely with the arrow keys, with no physics engine. After each update, it's pushed out of the deepest overlapping wall, up to 4 times in case one push moves it into another wall. Pushing along the smallest overlap makes it slide along walls, including the three rotated ones, instead of stopping.
I checked it with a script driving the example without a visible window:
get_collision_info's docs mention.While testing, my first layout had a gap narrower than the player between a rotated wall and the top wall. The player could get wedged there, pushed back and forth between the two walls. I moved that wall to leave room, and the random walk above was run on the final layout.
Docs:
doc/example_code/sprite_push_out.rstfollows the same format as the other example pages.Tests
test_get_collision_info_with_list: for everyCollisionMethod, with and without a spatial hash, it checks:get_collision_info,check_for_collision_with_list,test_get_collision_info_with_list_equal_depths: stable order for ties.collision.py.🤖 Generated with Claude Code