   [DirectX] Draw Tile map using Sprite
  I want to draw tile map using Sprite in DirectXEach tile is 48X48 and I use these tile to create a 10 X 10 map.And hence, I expect the map is 480X480.However, it is weird that the tiles drawn on the screen is 48 X 44 and the map is 480X440.What is the problem? THX[Edited by - s0962552 on May 31, 2010 6:59:26 PM]
  void DrawTile(LPDIRECT3DTEXTURE9 source,int tilenum,int width,int height,int columns,int destx,int desty){RECT r1;D3DXVECTOR3 pos(destx, desty,0);r1.left=(tilenum%columns)*width;r1.top=(tilenum/columns)*height;r1.right=r1.left+width;r1.bottom=r1.top+height;spriteobj->Draw(source,&r1,NULL,&pos,D3DCOLOR_XRGB(255,255,255));}-------------------------------------------------------------------------------void BuildGameWorld(){//fill the gameworld with tilesfor(int y=0;y<MAPH;y++){for(int x=0;x<MAPW;x++){DrawTile(tile,MAPDATA[y*MAPW+x],TILEH,TILEW,MAPW,x*TILEW,y*TILEH);}}};  Did you try to debug it to see the actuall values that are passed to DrawTile() and what happens with them in DrawTile()?And how does it look - are the tiles overlapping by 4 pixels or are the tiles stretched to 44 pixels so you can see the whole texture but deformed?   ;  MAPH and MAPW are both set to 10 and that TILEW and TILEY are set to 48The tile I used.http://img69.imageshack.us/img69/4805/mappo.pngThe Exe File:http://www.turboupload.com/5hr4vzcvp69r/tile.exe.htmlIf required, I will upload the code   ;  I would prefer a screenshot, not an exe file. This is something what can be fully shown on a picture, I am personaly not going to download a code and run it. Maybe someone else though.   ;  When you create your window, you should be using AdjustWindowRectEx to get the window size from the client size. If you don't do that, and pass the same values to both CreateWindowEx and CreateDevice, you'll get a backbuffer that is larger than the client area size, and you'll get stretching and other odd artefacts.   ;  Can you upload the code, please?  I would interested in taking a look.  Thanks.   ;Quote:Original post by Evil SteveWhen you create your window, you should be using AdjustWindowRectEx to get the window size from the client size. If you don't do that, and pass the same values to both CreateWindowEx and CreateDevice, you'll get a backbuffer that is larger than the client area size, and you'll get stretching and other odd artefacts.THX, the problem is solved. Now thw windows created is a square,but there is still some problem. It is 460 X 460 instead of 480X480.RECT clientRes = {0, 0, SCREENW,SCREENH};AdjustWindowRectEx(&clientRes,wc.style, true, NULL);HWND window = CreateWindowEx(NULL, APPTITLE.c_str(), APPTITLE.c_str(),  WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, clientRes.right - clientRes.left, clientRes.bottom - clientRes.top,NULL,NULL,hInstance,NULL);   ;Quote:Original post by sysop1911Can you upload the code, please?  I would interested in taking a look.  Thanks.OK,source code : http://www.zshare.net/download/7678472209708f54/   ;Quote:Original post by s0962552AdjustWindowRectEx(&clientRes,wc.style, true, NULL);The style you pass to AdjustWindowRectEx should be the window style, not the window class style. I.e. WS_OVERLAPPEDWINDOW in your case.   