Results 1 to 5 of 5

Thread: Tile Based Surface Issue.

  1. #1

    Thread Starter
    Member
    Join Date
    Dec 2001
    Location
    Chicago, IL
    Posts
    49

    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

  2. #2
    Fanatic Member
    Join Date
    Oct 2000
    Location
    Oregon
    Posts
    962
    I don't know much C, but this looks kinda odd:

    rcDest3.top = mMouse.GetXAxis();

    Notice that you are getting the X corretiant for the top value. Other then this I can see nothing wrong (but like I said I know VB not C).
    Involved in: Sentience

  3. #3

    Thread Starter
    Member
    Join Date
    Dec 2001
    Location
    Chicago, IL
    Posts
    49
    Well the RECT struct looks something like this..

    Top, Right ------------------ Top, Left
    | |
    | |
    | |
    | |
    | |
    Bottom, Right -------------- Bottom Left.

    So top is X, right is y, left is y + 32, bottom is x + 32

    I think thats ok, I just think my blitting is wrong or something, its starting to bug me

    - Darren

  4. #4
    Addicted Member
    Join Date
    Aug 2002
    Location
    Baltimore, MD
    Posts
    230
    I'm not sure why your RECT structure is reversed but it still doesn't match your code:

    rcDest3.top = mMouse.GetXAxis();

    Either this line is wrong or all of them are wrong.It looks like it should be:

    rcDest3.top = mMouse.GetYAxis();

  5. #5

    Thread Starter
    Member
    Join Date
    Dec 2001
    Location
    Chicago, IL
    Posts
    49
    Yes, your right, I changed it, however, the tile still goes right back to 0,0 lol *cry*

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width