|
-
Dec 16th, 2002, 11:50 AM
#1
Thread Starter
Member
Tile Based Surface Issue.
Hi guys, all of my code is in c++, but my guess is the same should apply for VB. I am using the Direct Draw 7 interface to create a small tile editor for my tile based game. The problem is (i think) quite simple, I just cant seem to get it to work. Right now all I am concentrating on, is attaching a tile to my cursor and plonking it down somewhere on the screen. Here is some code fragments..
First off inside an initialize function, create the surfaces then load a bitmap onto my surface (I think this is where things might be going wrong). I have 3 surfaces, backdrop, tileset and my mousedrag surface that the tile will move around the screen based on mouse coordinates.
Code:
if( FAILED (lpdd7->CreateSurface(&ddsd, &lpddsTileset, NULL)))
return(FALSE);
if( FAILED (lpdd7->CreateSurface(&ddsd, &lpddsBackdrop, NULL)))
return(FALSE);
if( FAILED (lpdd7->CreateSurface(&ddsd, &lpddsMouseDrag, NULL)))
return(FALSE);
if(!Load_Bitmap(MAKEINTRESOURCE(IDB_BACKGROUND), 0, 0, lpddsBackdrop))
return(FALSE);
if(!Load_Bitmap(MAKEINTRESOURCE(IDB_BITMAP1), 0, 0, lpddsTileset))
return(FALSE);
if(!Load_Bitmap(MAKEINTRESOURCE(IDB_BITMAP1), 0, 0, lpddsMouseDrag))
return(FALSE);
When I blit the background and tileset they work just fine. However, in the main render loop, I have this problem. I get the coordinates of the mouse and set my rectangle for blitting to a 32x32 square, with the top right being the mouse coordinates, then I blit the tile I want into that rectange, like so..
Code:
rcDest3.top = mMouse.GetXAxis();
rcDest3.bottom = mMouse.GetYAxis() + 32;
rcDest3.right = mMouse.GetXAxis() + 32;
rcDest3.left = mMouse.GetXAxis();
byTile = byMap[0][1][0];
lpddsBack->Blt(&rcDest3, lpddsMouseDrag, &lptile[byTile]->rcLocation , DDBLT_WAIT, NULL);
What happens is it attaches to my mouse pointer just fine, but each time it keeps itself in a square in the top right hand corner of the screen, when ever I move the mouse it just goes right back to the top right (0,0 is my guess). I also get like a trail effect of the tile. Its very hard to explain 
If you need additional code, or want the program and resource files, let me know and I will attach them. I look forward to anyones help!
- Darren
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|