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

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




PostPosted: Sat Feb 09, 2008 9:12 pm   Post subject: collision detection

Hello fellow programmers, I need help on collision detection for sprites. I can make it work with whatdotcolor , but that is only for walking right and left, it doesn't work for jumping. I was also wondering if there is another way to do it because whatdotcolor depends on the background. It would be good to have an example since im a begginer in programming..please
Sponsor
Sponsor
Sponsor
sponsor
CodeMonkey2000




PostPosted: Sat Feb 09, 2008 10:15 pm   Post subject: RE:collision detection

When you are jumping you have to check all around the image (ie the perimeter). Whatdotcolour is very inefficient that way, you can take a few short cut, but it will get less precise.
richcash




PostPosted: Sat Feb 09, 2008 10:23 pm   Post subject: Re: collision detection

Can your sprites be broken down and approximated into a polygon or a number of ovals/boxes? If so, you can use mathematical methods to calculate the collision detection. If not, then I suppose you're stuck with whatdotcolour.

As CodeMonkey said, you have to iterate over the entire perimeter with whatdotcolour. But, you should use bounding boxes or bounding ovals (or even bounding polygons) depending on the shape of your character to avoid checking each point on the perimeter when the character is not even close to anything.
CodeMonkey2000




PostPosted: Sun Feb 10, 2008 4:37 pm   Post subject: RE:collision detection

If you still want to use whatdolor ,here is a tutorial I dug up in the tutorials section. Remember your game will be very slow if you do it this way.

http://compsci.ca/v3/viewtopic.php?t=8175
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  [ 4 Posts ]
Jump to:   


Style:  
Search: