Thread: tile game border

  1. #1
    Registered User
    Join Date
    Oct 2002

    tile game border

    I have recently been porting my unfinished RPG from DirectX 7 to DirectX 8. Im doing this because I really want to learn something I can use for quite a while in the future and DirectX 7 seems like a dead end. I really like DirectX 7 and was getting pretty good, but I think it is time to switch so that I can learn DirectX 8. Im doing fine up until now but have one question that I can't seem to find anywhere. I was wondering how I would go about programming a border around my tiled graphics. The tiles are constantly moving when the character moves, and the way it is set up now is that the very last tile on the far right disappears as the tiles shift to the right, so that the graphics don't go out side of the boundaries causing an error. With DirectX 7 it was okay to draw outside of the screen, but causes an error in DirectX 8. My solution to this (I think) would be to place the border over the outside tiles, so that the disapearing tiles will not be seen. Is this possible, and am I going about this the proper way? Also, should I use a texture that is very large with alpha blending to show the inside of the screen? Any input would be great. Im probably doing this all wrong, but I can't seem to find answers anywhere on the net as it is so specific of a question. Thank you and hope someone can help.
    "The distinction between past, present and future is only an illussion, even if a stunning one."
    -Albert Einstein

  2. #2
    mov.w #$1337,D0 Jeremy G's Avatar
    Join Date
    Nov 2001
    The proper way to deal with your disapearing tiles is clipping them, and allways drawing the portion still on screen. However if you are happy enough with 'half assing' it feel free.

    Perhaps you might want to create a whole screen buffer just for the border - draw the border once, and everything in the center a specific color (not seen in th border). Then right before you flip your drawing buffer to the front - blast your border buffer onto it using a transparent copy. Hope you get what i mean.
    (it should be realized my posts are all in a light hearted manner. And should not be taken offense to.)

  3. #3
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Either attach a DirectDraw clipper to the window or use Direct3D to render your tiles. Direct3D will clip at the screen edges. Draw your tiles as a triangle strip - one tile is 2 triangles, set the texture for the quad, and render it via D3D. Check out's tutorial on how to use Direct3D to render 2D tiles - in the Isometric Game programming section under Articles and Tutorials.

  4. #4
    carry on JaWiB's Avatar
    Join Date
    Feb 2003
    Seattle, WA
    I've noticed that when you use a clipper, it seems to wrap things when they go off screen (at least I think it is a side effect of using Direct Draw clippers) You may want to watch out for that if you decide to use them
    "Think not but that I know these things; or think
    I know them not: not therefore am I short
    Of knowing what I ought."
    -John Milton, Paradise Regained (1671)

    "Work hard and it might happen."

  5. #5
    Registered User
    Join Date
    Oct 2002
    I didn't think using a whole screen buffer for the border was proper, but that is what I thought of doing. Also, I am using Direct3D to render the tiles, but the first map array of tiles is just a regular bit blit using a surface, since the first layer does not need to be transparant. The second layer is done with alpha blending so that transparancy could be used. I did this becasue I thought it would be faster, but it probably is not. It seems that Direct3D is not automatically clipping it for me, but this may be because my first tile layer is a surface? I think I like 'dbgt goten's ' idea the best. Wouldn't this be more efficient than using both clipping and drawing a border? Since I will need a border anyways, I might as well use it to cover the disapearing tiles and not use clipping? Kind of like killing two birds with one stone? Im probably wrong, but it just seems logical. Thank you all for your input, and I will definately check out the links posted for me.

    PS: This web site has been my favorite place for answers so far, and has helped me greatly. I'd like to thank everyone who makes the site possible, and also all of the talented users who do the helping. Cheers!
    "The distinction between past, present and future is only an illussion, even if a stunning one."
    -Albert Einstein

  6. #6
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    int TileEngine::Render(int offset_x,int offset_y)
      D3DTLVERTEX Vertex[4];
      Vertex[0].tu = 0.0f; 
      Vertex[0].tv = 0.0f; 
      Vertex[1].tu = 1.0f; 
      Vertex[1].tv = 0.0f; 
      Vertex[2].tu = 0.0f; 
      Vertex[2].tv = 1.0f; 
      Vertex[3].tu = 1.0f; 
      Vertex[3].tv = 1.0f;
      SampleTexture=new TileTexture();
      int screen_x=-128,screen_y=-64;
      int tile_x=0,tile_y=0;
      while (screen_y<ScreenHeight)
         while (screen_x<ScreenWidth)
    This sample clips fine for me...just need to set textures according to tile and actually use some tile map logic to get the map to display correctly.

  7. #7
    Registered User
    Join Date
    Oct 2002
    Thanks for the above info. I havn't been around in a while so I just wanted to make sure I thanked you for the above code. I copied pasted it to keep - thanks a million!
    "The distinction between past, present and future is only an illussion, even if a stunning one."
    -Albert Einstein

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. how do the game engine and the api interact?
    By Shadow12345 in forum Game Programming
    Replies: 9
    Last Post: 12-08-2010, 12:08 AM
  2. Engine <=> DX/OGL | c++ ?
    By darkcloud in forum Game Programming
    Replies: 6
    Last Post: 05-13-2005, 12:19 AM
  3. Game Designer vs Game Programmer
    By the dead tree in forum Game Programming
    Replies: 8
    Last Post: 04-28-2005, 09:17 PM
  4. Game structure, any thoughts?
    By Vorok in forum Game Programming
    Replies: 2
    Last Post: 06-07-2003, 01:47 PM
  5. Tile Editor
    By Nick in forum Linux Programming
    Replies: 3
    Last Post: 08-10-2001, 11:24 PM