sub unionall {
my ($self, $rects) = (@_);
- croak "must receive an array reference of SDL::Rect-based objects"
- unless defined $rects and ref $rects eq 'ARRAY';
+ unless (defined $rects and ref $rects eq 'ARRAY') {
+ croak "must receive an array reference of SDL::Rect-based objects";
+ }
my ($x, $y, $w, $h) = _test_unionall($self, $rects);
sub unionall_ip {
my ($self, $rects) = (@_);
- croak "must receive an array reference of SDL::Rect-based objects"
- unless defined $rects and ref $rects eq 'ARRAY';
+ unless (defined $rects and ref $rects eq 'ARRAY') {
+ croak "must receive an array reference of SDL::Rect-based objects";
+ }
my ($x, $y, $w, $h) = _test_unionall($self, $rects);
return _do_rects_intersect($self, $rect);
}
+sub collidelist {
+ my ($self, $rects) = (@_);
+
+ unless (defined $rects and ref $rects eq 'ARRAY') {
+ croak "must receive an array reference of SDL::Rect-based objects";
+ }
+
+ for(my $i = 0; $i < @{$rects}; $i++) {
+ if ( _do_rects_intersect($self, $rects->[$i]) ) {
+ return $i;
+ }
+ }
+ return;
+}
+
+
42;
__END__