1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
|
void CEntityManager::CreateTileMap()
{
RECT rectSrc;
HRGN hRgn1=NULL;
HRGN hRgn2=NULL;
HRGN hRgnResult=NULL;
POINT RGNPoints[4];
int x,y,n;
int j;
int index;
int nVal;
sBaseObject *pObject=NULL;
int i=0;
index=0;
int nOffset=256;
for(n=0;n<m_vecBaseOBjects.size();n++)
{
pObject=m_vecBaseOBjects[n];
if(pObject->nLayer>=2)
{
for(j=0;j<4;j++)
{
RGNPoints[j].x=pObject->nPosX+pObject->ptCollisionEdges[j].x;
RGNPoints[j].y=pObject->nPosY+pObject->ptCollisionEdges[j].y;
}
hRgn2=::CreatePolygonRgn(RGNPoints, sizeof(RGNPoints)/sizeof(POINT),WINDING);
index=0;
for(y=0;y<MAX_TILES;y++)
{
for(x=0;x<MAX_TILES;x++)
{
rectSrc.left =x * TILE_SIZE;
rectSrc.top =y * TILE_SIZE;
rectSrc.right =rectSrc.left+TILE_SIZE;
rectSrc.bottom =rectSrc.top +TILE_SIZE;
hRgn1=::CreateRectRgn (rectSrc.left ,rectSrc.top,rectSrc.right,rectSrc.bottom);
hRgnResult = CreateRectRgn( 0, 0, 10, 10 );// bidon NE SURTOUT PAS MODIFIER
nVal=::CombineRgn(hRgnResult,hRgn1,hRgn2,RGN_AND);
::DeleteObject( hRgnResult );
::DeleteObject( hRgn1 );
if(nVal!=0)
{
if(nVal!=NULLREGION)
{
rectSrc.left =x * TILE_SIZE;
rectSrc.top =y * TILE_SIZE;
rectSrc.right =rectSrc.left+TILE_SIZE;
rectSrc.bottom =rectSrc.top +TILE_SIZE;
g_vecExclRectangles.push_back (rectSrc);
//++ m_vecExclRectangles.push_back (rectSrc);
}
}
index++;
}
}
::DeleteObject( hRgn2 );
}
}
} |
Partager