Skip to main content
gamedev.net
🔒 Locked

Simple Collision Detection

Started by mesHead Nov 27, 2000 at 3:50 PM 4 replies 400+ views
Original Post
mesHead
mesHead
Hi! I was wondering if anyone knows where I can find some tutorials on very basic collision detection. I am VERY new at collision detection and such, so the simpler the tutorial the better. ( all I''m trying to learn is how to detect a simple collision between two 2D square polygons. very, very simplistic :D ) Thanks in advance to all those who reply. -- Keith. mesHead.
mesHead
oglman
oglman
I will continue plugging this unitl people stop saying how good it is Collision code. It requires no math!!




Open mouth, insert foot
dusik
dusik
Yeah, but how would you do pixel-perfect collision detection? Just wondering... Perhaps if, for every bitmap, you also have a 1-bit-per-pixel bitmap, and you AND the two 1-bit bitmaps onto a large 1-bit-deep bitmap filled with 1''s, you could see if you have any 1''s left in the resulting large bitmap.... but that would be kinda inefficient I think.

------------------------
CRAZY_DUSIK* pCrazyDuSiK;
pCrazyDuSiK->EatMicroshaft(MS_MUNCH_BILL_GATES | MS_CHEW_BILL_GATES);
------------------------CRAZY_DUSIK* pCrazyDuSiK = new CRAZY_DUSIK;pCrazyDuSiK->EatMicroshaft(MS_MUNCH_BILL_GATES | MS_CHEW_BILL_GATES);pCrazyDuSiK->WebSiteURL = "http://www.geocities.com/dusik2000";
Beelzebub
Beelzebub
You''re right, by itself it isn''t wonderfully inefficient, but you can:
i. precalculate these monochrome bitmasks for every frame of animation, but if you haven''t the memory only re-calculate them when the animation frame changes.

ii. precalculate/generate_on_the_fly a column mask - where you OR together all the rows of each column of the mask from i. This gives you a very quick check as whether you need to do the compulationaly expensive check.
This works well for objects moving horiztonally (relative to each other), for relative vertical motion generate row masks based on the columns.

Not forgetting that you can do really quick checks on intersections of bounding rectangles before any of this.


Using all of these works well, even on low performance machines such as the GameBoy Colour.
dusik
dusik
Yeah, Beelzebub, you''re right

Unfortunately, you can''t really do that in 3D, hence there are always clipping bugs... I''m developing a 3D engine. We''ll see what can come up with, but clipping, etc. is still ways off. I mean, I just started at the end of August, and now I''m converting to DX8... I think DX8 is kinda messy. It seems simpler, but some things don''t make sense until you ponder for a while.

------------------------
CRAZY_DUSIK* pCrazyDuSiK;
pCrazyDuSiK->EatMicroshaft(MS_MUNCH_BILL_GATES | MS_CHEW_BILL_GATES);
------------------------CRAZY_DUSIK* pCrazyDuSiK = new CRAZY_DUSIK;pCrazyDuSiK->EatMicroshaft(MS_MUNCH_BILL_GATES | MS_CHEW_BILL_GATES);pCrazyDuSiK->WebSiteURL = "http://www.geocities.com/dusik2000";

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.