collision detection
Author |
Message |
metachief

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

|
|
 |
CodeMonkey2000
|
Posted: 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
|
Posted: 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
|
Posted: 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 |
|
|
|
|
 |
|
|