Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

2D All the way! / I need to know how to make bounding rectangle collision happen

Author
Message
Long Striker
20
Years of Service
User Offline
Joined: 16th Apr 2005
Location:
Posted: 28th Apr 2005 07:25
I have a 2D fighter and dont know how to make rectangle collisions work. Or some other kind of collision dection Plz help!
zenassem
22
Years of Service
User Offline
Joined: 10th Mar 2003
Location: Long Island, NY
Posted: 2nd May 2005 09:53
Longstriker,

You could look at the Sprite Collision command. To be honest I'm not sure if evertything has been fixed with Sprite Collision and Sprite Hit commands. I remeber getting some odd results a while back with them. I believe Sprite Collision tests for bounding rectangles of two sprites automatically while Sprite Hit was for pixel perfect collision. Since I had some problems with the command I just made my own test for bounding rectangles. I jus created my own data type called rect that had eight integer values tlx, tly, trx, try, blx, bly, bry. Standing for (top left x, top left y etc...). I would then use this type to keep track of the rectangle around my sprite. Then it's just a matter of comparing the proper values to determine a collision.

Perhaps someone can specify whether Sprite Collision and Sprite Hit work properly now. I'll have to do some tests to see if they work. As far as I can remember, I was getting different results depending on which sprite I used as the target sprite. Which was pretty strange.

~zenassem


D Ogre
21
Years of Service
User Offline
Joined: 19th Nov 2003
Location:
Posted: 3rd May 2005 08:39
It depends on which language we are talking about, DBC or DBPro. The sprite collision for DBC works, but one the other hand, DBPro has problems with its collision.

Since DBPro uses 3D for its sprites in order to utilize 3D harware acceleration, the collision does not work the same as DBC. At best, you get box collision with sprites in DBPro. Forget about getting anything close to pixel perfect collision. If you need PPC, you can use a function written by IanM. The code is 100% DBPro code (No plugins). The code works reasonably well in most cases. Make sure you enable transparencies on your sprites. You will need to look for it in the codebase.

Login to post a reply

Server time is: 2025-05-17 16:17:38
Your offset time is: 2025-05-17 16:17:38