Tile editor isometric test

This is a discussion on Tile editor isometric test within the Game Programming forums, part of the General Programming Boards category; Well since I'm waiting for models on my 3D game or moreso waiting to figure out how to get the ...

  1. #1
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,584

    Tile editor isometric test

    Well since I'm waiting for models on my 3D game or moreso waiting to figure out how to get the models, I figured I try to do an isometric version of my editor and tile engine.

    Here is my first test and so far it looks ok. The row and column numbers are correct in this screenshot.

    However I really have no idea how to convert from mouse x,y to row,col. Once I figure that out I should be able to simply call a Calculate function which will transform coords from mouse x,y to row,col based on the current view mode.

    Just toying around and not sure how far I'll go with it.
    Last edited by VirtualAce; 03-12-2011 at 10:41 AM.

  2. #2
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,584
    I think I figured it out.

    This little handy dandy bitmap is a lifesaver. I remembered this approach from an article about Civ 1.

    Basically this bitmap tells me how I must increment/decrement the row/column to get what cell the player is pointing at.

    Blue=(row,col-1)
    Red=(row-1,col)
    Yellow=(row+1,col)
    Green=(row,col+1)
    White=(row,col)

    The offset into the image is:

    Code:
    int v=(iCursorX-iTileX)/iTileWidth;
    int u=(iCursorY-iTileY)/iTileHeight
    
    if (mask(u,v))==BLUE) col--;
    if (mask(u,v))==RED) row--;
    if (mask(u,v))==YELLOW) row++;
    if (mask(u,v))==GREEN) col++;
    With a 2D flat map I was snapping the grid to the upper left corner of the grid, but width and height were the same. Here I'm snapping the grid to the upper left corner, but height is halved and width is doubled.
    By accessing texels in this texture I can alter those calculations to fit the grid on screen.
    Last edited by VirtualAce; 03-12-2011 at 10:41 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Integer Emulation
    By Elysia in forum C++ Programming
    Replies: 31
    Last Post: 03-18-2008, 01:03 PM
  2. Need testers for editor
    By VirtualAce in forum Game Programming
    Replies: 43
    Last Post: 07-10-2006, 08:00 AM
  3. C++ Operator Overloading help
    By Bartosz in forum C++ Programming
    Replies: 2
    Last Post: 08-17-2005, 12:55 PM
  4. MSVC Template Constructor/Assignment Errors
    By LuckY in forum Windows Programming
    Replies: 3
    Last Post: 07-22-2005, 02:57 PM
  5. Tile Editor
    By Nick in forum Linux Programming
    Replies: 3
    Last Post: 08-10-2001, 11:24 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21