From: Breno G. de Oliveira Date: Sun, 4 Oct 2009 07:43:14 +0000 (-0300) Subject: implemented collidelistall X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=dfbe9a274a5315b340b154a6af5ea0f43ffd5d52;p=sdlgit%2FSDL_perl.git implemented collidelistall --- diff --git a/lib/SDL/Game/Rect.pm b/lib/SDL/Game/Rect.pm index 470fd65..dc883f8 100644 --- a/lib/SDL/Game/Rect.pm +++ b/lib/SDL/Game/Rect.pm @@ -649,6 +649,21 @@ sub collidelist { return; } +sub collidelistall { + my ($self, $rects) = (@_); + + unless (defined $rects and ref $rects eq 'ARRAY') { + croak "must receive an array reference of SDL::Rect-based objects"; + } + + my @collisions = (); + for(my $i = 0; $i < @{$rects}; $i++) { + if ( _do_rects_intersect($self, $rects->[$i]) ) { + push @collisions, $i; + } + } + return \@collisions; +} 42;