in reply to Re: Re: Collision detection quandry
in thread Collision detection quandry
I don't have time to finish this right now, but hope it helps.my $transparent_color = ' '; my $chardata = [ ' |x x|', ' | |', ' = ', ]; my $map = make_collision_map($chardata); # This gives you a map like so #00000000000000000000000000110110 #00000000000000000000000000100010 #00000000000000000000000000001000 # Assuming the character animations is an array ref of one or more hor +izontal lines sub make_collision_map { my $sprite = shift; my @mask; foreach my $row (@$sprite){ warn "Sprite length exceeds limit:[$row]" and return if length($ +row) > 32; (my $bits = $row)=~s/[^$transparent_char]/1/g; $bits=~s/$transparent_char/0/g; push @mask, unpack("N", pack("B32", substr("0" x 32 . reverse ( +$bits), -32))) ; } return [@mask]; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: (3): Collision detection quandry
by robobunny (Friar) on Feb 06, 2004 at 22:04 UTC |