   Collission detection?
  Hey guys, I need alittle help in collission detection. Im using a graphics path to draw my object or matrix. As well as bullets and then Im using bitmaps to draw other obstacles and tiles. Now I need to use this graphics path to determine if Im colliding with the other bullets or objects and also certain tiles.I could really use some help on this, thanks all for your help.   
  Hello Kunark,It could be me, but I don't think it is entirely clear what you mean with graphics path. If a problem is hard to explain, you might want to use pictures/screenies or bitmaps. An image usually says more then 100 words...Hope this helps this thread,Xeile   ;  Oh sorry about that, Well I've gotten alittle further and then I ran into a problem. The server I'm using is just a dialog box that does the calculations. My objects though are regions so I've done all the code to make the regions ect, then I find out you need to create a graphics to see if they region is empty. Well to create a graphics you need a DC but since Its dialog I don't have a dc. So currently Im trying to figure out how to create a CDC that is of the size of the window that is used on my actual client which is a view. If you are able to help me I would greatly greatly appreciate it.Here is the code I have currently.// Basically, determine if the object is within view, that means there could be a collission// Hopefully optimizes the calling of our Collission detection.bool IsInView(float fX, float fY){return (fX >= m_fXPos -(1000/2) && fX < m_fXPos+(1000/2) && fY >= m_fYPos-(550/2) && fY < m_fYPos+(550/2));}// Determine if the buggies collidedbool IsCollission(CBuggieServer* pObject){// We will be creating this DC laterCDC * pDC;pDC->CreateDC(// Graphics Paths for both objectsGraphicsPath gpObject1;GraphicsPath gpObject2;// These are both buggiesgpObject1.AddLine(REAL(-10), REAL(-30), REAL(10), REAL(-30));gpObject1.AddLine(REAL(10), REAL(-30), REAL(15), REAL(40));gpObject1.AddLine(REAL(15), REAL(40), REAL(-15), REAL(40));gpObject1.AddLine(REAL(-15), REAL(40), REAL(-10), REAL(-30));gpObject2.AddLine(REAL(-10), REAL(-30), REAL(10), REAL(-30));gpObject2.AddLine(REAL(10), REAL(-30), REAL(15), REAL(40));gpObject2.AddLine(REAL(15), REAL(40), REAL(-15), REAL(40));gpObject2.AddLine(REAL(-15), REAL(40), REAL(-10), REAL(-30));// The regions that our buggies occupy   Region rObject1 (&gpObject1);Matrix matObject1;matObject1.Translate(m_fXPos, m_fYPos);matObject1.Rotate(m_fHeading);rObject1.Transform(&matObject1);Region rObject2 (&gpObject2);Matrix matObject2;matObject2.Translate(pObject->GetXPos(), pObject->GetYPos());matObject2.Rotate(pObject->GetDir());rObject2.Transform (&matObject2);// generate intersection//Region * rIntersect = rObject2.Clone();//rIntersect->Intersect(&rObject1);// That will generate a region of the intersecting buggies// So lets see if there was a collisonreturn rObject2.Intersect(&rObject1);};  What?That isn't any clearer at all.We have no idea what you're building, or what (seems to be) physics/graphics/whaterver api you are using.;  Okay, I don't know how I can make it more clear, I guess I can state that Im using MFC. Other than that what else can I give you, thats the code to draw my object which is a buggie. That I'm using regions, which you can see in my code. That each buggie has a logical x,y coordinate which you can also see. Instead of getting angry why don't you ask what you need? I can't read minds and this is the first time I'm doing this type of thing so I wouldn't know what you need. Does collission detection matter on the API? Figured API was just for what you see, and you shouldn't have to see the buggie to do collission detection though maybe its just me.   ;Quote:Original post by Surg AKA KunarkOkay, I don't know how I can make it more clear, I guess I can state that Im using MFC. Other than that what else can I give you, thats the code to draw my object which is a buggie. That I'm using regions, which you can see in my code. That each buggie has a logical x,y coordinate which you can also see. Instead of getting angry why don't you ask what you need? I can't read minds and this is the first time I'm doing this type of thing so I wouldn't know what you need. Does collission detection matter on the API? Figured API was just for what you see, and you shouldn't have to see the buggie to do collission detection though maybe its just me.Nope, you sure can't read minds. If you could, you'd know that I'm not angry.Ohwell, sorry I don't use MFC, all I know about collision detection is homebrew stuff. You'll have to wait for someone else who uses it if the issue is MFC specific.*shrug*Why not just write the collision detection from scratch? You mentioned bitmaps and tiles so it sounds like you are doing a 2d game. Checking if a bullet is hitting a wall tile is easy, you just have box collisions. And due to the grid nature of a tiled game its easy to find what tiles your bullet is possibly going to collide with, just take its x,y coordinates and divide by tile width to get the tile row and column....   ;  Aye yea, hence the problem, I don't want box hit detection your right that would be fairly simple. I want it to if my object is slanted and jagged, it doesn't collied unless the actual jagged edge is hit, not a box around the item. But I think Ill be able to get it, Ive almost got it just depends on which side u enter the player from. Thanks again for anyones help.   ;  Just how 'jagged' an edge are we talking about?Simple stuff like walls that are diagonal? That could be handled by a simple polygon or line test, after the box collision says there was a Possible hit.If you want bitmap/pixel collisions.... well, I don't use bitmaps, only polygons... Someone might be able to suggest some fun bit/memory comparision that tells you if two bitmaps overlap or not.Keep in mind that a bitmap is just a lot of littler boxes like your map tiles in general. So you could potentially do it from scracth using brute force pixel/box checks, if you first lower it down to Just the one bitmap via larger box/tile checks first.   