Well I got that part worked out... It draws the map fine but now I have another problem - that is smooth movement around the map. Right now for some reason the tiles JUMP as you move. I found how to fix that, but when I fix that is messed up my drawing boundaries! Here is the code I am using, maybe someone can figure out where I am going wrong...
bool DrawTiles(){ int x, y, i; RECT rcDest; BYTE byTile; // Tile location of the upper left corner of the screen int xStart = mapData.xScreen / 44; // xScreen is the pixel coordinate for movement int yStart = mapData.yScreen / 44; // yScreen is the pixel coordinate for movement // Set the RECT of the first tile to be drawn rcDest.left = xStart * 44 - mapData.xScreen; rcDest.top = yStart * 44 - mapData.yScreen; rcDest.right = rcDest.left + 44; rcDest.bottom = rcDest.top + 44; RECT rcTemp = rcDest; // Will need a backup! for(x=0; x<30; x++) { // if we are on an odd row, i will be TRUE i = (x+2)%2; // increment the RECT for the next tile rcDest.top += 22; rcDest.bottom += 22; rcDest.left = rcTemp.left; rcDest.right = rcTemp.right; if(i) { // offset the RECT and tile coord for an odd row yStart += 1; rcDest.left -= 22; rcDest.right -= 22; } else { // on an even row, increment the coord down 1 full tile if(x > 0) xStart += 1; } for(y=0; y<18; y++) { // current tile coords being drawn xCurr = xStart + y; yCurr = yStart - y; // increment the bounding RECT rcDest.left += 44; rcDest.right += 44; // make sure we arent drawing past the map limits if(xCurr >= 0 && xCurr <= mapData.xMax && yCurr >= 0 && yCurr <= mapData.yMax) { // this is just a makeshift linked list for testing, it works for now i = mapLoc[xCurr][yCurr].nNumTiles-1; byTile = mapLoc[xCurr][yCurr].tileData[i].byTile; // if there is a tile in that spot, BLT it!! if(byTile > 0) g_pDDSBack->Blt(&rcDest, mapData.pDDSTileset, &lptileInfo[byTile]->rcLocation, DDBLT_WAIT | DDBLT_KEYSRC, NULL); } } } return true;}
|
Excuse me if it looks a little sloppy, I am trying to get it WORKING before I go optimize every little detail

As you can see, mapData.xScreen and mapData.yScreen are the pixel coords of the map, and somewhere between that and the starting RECT are where I think my problems are...
PLEASE HELP!
Thanks in advance