Posted: Fri Dec 18, 2009 7:30 pm Post subject: Sprite Collision
Exactly what the title says I just want to know how to make sprites collide because whatdotclolor doesn't work with sprites.
I could use Math.Distance but I wanted to know if there was an easier way
Sponsor Sponsor
Zren
Posted: Fri Dec 18, 2009 9:36 pm Post subject: RE:Sprite Collision
Rectangular Collision Detection. However, that's harder that Circular Collision Detection (Math.Dist). But would be more realistic with Rect and is worthwhile learning.
http://compsci.ca/v3/viewtopic.php?t=13661
From there (Rect C. D.), you could even do Per-Pixel Collision Detection.
Tony
Posted: Fri Dec 18, 2009 9:40 pm Post subject: Re: RE:Sprite Collision
Zren @ Fri Dec 18, 2009 9:36 pm wrote:
From there (Rect C. D.), you could even do Per-Pixel Collision Detection.
FYI, per-pixels can be approximated with circles about as well.
Posted: Fri Dec 18, 2009 10:06 pm Post subject: RE:Sprite Collision
Well, every sprite has an X and Y coordinate (I hope you're drawing from the corners, and not the middle). Thus you can get the other corner, x+width and y+height. Hey, that's a rectangle! You can use rectangular collision detection here.
Zren
Posted: Fri Dec 18, 2009 10:55 pm Post subject: Re: RE:Sprite Collision
Tony @ Fri Dec 18, 2009 9:40 pm wrote:
Zren @ Fri Dec 18, 2009 9:36 pm wrote:
From there (Rect C. D.), you could even do Per-Pixel Collision Detection.
FYI, per-pixels can be approximated with circles about as well.
True. Though it'll trigger the second step more often than not with long rectangles and probably show no collision. And unless you think to set the radius as one of the corners, you'll possibly miss a collision.
Btw, do you know a tutorial of some sort of P-P C.D.? I swear I've heared of it from this site in turing, but now that I think of completely reading up on the algorithm, I can't find it.