Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Sprite Collision
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
drummaboy




PostPosted: 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
Sponsor
sponsor
Zren




PostPosted: 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




PostPosted: 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.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Insectoid




PostPosted: 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




PostPosted: 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.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 5 Posts ]
Jump to:   


Style:  
Search: