ISO3D Tile Selection
Hello,
i have read the book "Isometric Game Programming with DirectX 7.0" and in the last Chapter TRANSTAAFL told me how to do a Tile Selection in ISO3D, but i don''t understand this.
I make a Surface for the MouseMap, and each Row have a Color.
So, when i click on the Mouse, i read the MouseMap-Surface Pixel at the Mouse-Coordinate.
And, then????
How i can transform the WORD Color into the Map-Location???
Have somebody a Code for this stupid Problem???
My CodeBy Mouse-Click)
POINT Convert_Color_Tile(POINT ptMousePos)
{
POINT ptTemp;
DDSURFACEDESC2 ddsd;
memset(&ddsd,0,sizeof(DDSURFACEDESC2));
ddsd.dwSize=sizeof(DDSURFACEDESC2);
lpddsMouseMap->Lock(NULL,&ddsd,DDLOCK_WAIT,NULL);
LONG lPitch = ddsd.lPitch/sizeof(WORD);
WORD* pSurface = (WORD*)ddsd.lpSurface;
WORD dwColor = pSurface[ptMousePos.x+ptMousePos.y*lPitch];
lpddsMouseMap->Unlock(NULL);
// Here is the Problem...what must i do with the Color?
return ptTemp;
}
I hope somebody have read the book too, and can help me. I relly don''t know how to do this!
Cya
MC Agni
I''m not sure about that specific book... but the general method is thus.
The maths above are assuming you show the map by interleaving the odd rows by moving the tiles over half a column. But that is the basic concept; use the color to determine exactly which tile to shove the "real" cursor position into.
----------------------|Blue /\ Green|| / \ || / \ ||/ White \||\ /|| \ / || \ / ||Magenta \/ Red |----------------------
switch (dwColor) { case COLOR_WHITE: // Clicked on this tile. break; case COLOR_BLUE: if (ptTemp.y is even) ptTemp.x--; ptTemp.y--; break; case COLOR_GREEN: if (ptTemp.y is odd) ptTemp.x++; ptTemp.y--; break; case COLOR_MAGENTA: if (ptTemp.y is even) ptTemp.x--; ptTemp.y++; break; case COLOR_RED: if (ptTemp.y is odd) ptTemp.x++; ptTemp.y++; break; default: break;}
The maths above are assuming you show the map by interleaving the odd rows by moving the tiles over half a column. But that is the basic concept; use the color to determine exactly which tile to shove the "real" cursor position into.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement