No problem. Seeing that your using console graphics, I'm assuming you are going to want to detect collisions on the character level. If that's the way you go, once you get things working to your liking you could make it speedy and less memory hungry by creating bitmasks of the sprites and judicious use of bitwise &, and bit shifts. Let's say you limit sprites to 32 x 32 (pretty big for ascii characters), You could make a bit mask for the characters with something like so... (untested) Then by comparing the appropriate rows, collision checking can be done with a bitwise & (After you've shifted the mask appropriately )
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]; }
I don't have time to finish this right now, but hope it helps.

-Lee

"To be civilized is to deny one's nature."

In reply to Re: (3): Collision detection quandry by shotgunefx
in thread Collision detection quandry by robobunny

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.