From 7a768a915884428ba15ddaf03f51f2da44129dfe Mon Sep 17 00:00:00 2001 From: Lily Seabreeze Date: Wed, 7 Sep 2016 01:07:58 -0500 Subject: [PATCH] implemented hopefully most of the collision tests --- tests/test_collide.py | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/tests/test_collide.py b/tests/test_collide.py index f2e6f08..94ab256 100644 --- a/tests/test_collide.py +++ b/tests/test_collide.py @@ -17,17 +17,22 @@ path, mask_threshold=254 ) - animsprite_mask_20_20.rect.topleft = (20, 20) animsprite_mask_40_40 = animate.AnimatedSprite.from_gif( path, mask_threshold=254 ) - animsprite_mask_40_40.rect.topleft = (40, 40) -animsprite_group_sans_one = pygame.sprite.Group(animsprite_mask_40_40) +animsprite_20_43 = animate.AnimatedSprite.from_gif( + path, + mask_threshold=254 +) +animsprite_20_43.rect.topleft = (20, 43) + +animsprite_group_sans_one = pygame.sprite.Group(animsprite_mask_40_40, + animsprite_20_43) def test_move_close_as_possible(): @@ -53,3 +58,20 @@ def test_move_close_as_possible(): ) assert closest_to_goal == (10, 10) assert collided_with is None + + closest_to_goal, collided_with = collide.move_as_close_as_possible( + animsprite_mask_20_20, + (20, 60), + animsprite_group_sans_one + ) + assert closest_to_goal == (20, 33) + assert collided_with is animsprite_20_43 + + +def test_sprites_in_orthogonal_path(): + collided_with = collide.sprites_in_orthogonal_path( + animsprite_mask_20_20, + (20, 60), + animsprite_group_sans_one + ) + assert collided_with[0] is animsprite_20_43